dateutils icon indicating copy to clipboard operation
dateutils copied to clipboard

dateconv -E seems incompatible with -S

Open Earnestly opened this issue 3 years ago • 4 comments

The intention is to use dateconv -S to convert strings which match but exclude lines which do not.

E.g. Currently:

% printf '%s\n' '01-03-2004 foo' 'bar baz' | dateconv -Si %d-%m-%Y -f %F
2004-03-01 foo bar
bar baz
% printf '%s\n' '01-03-2004 foo' 'bar baz' | dateconv -ESi %d-%m-%Y -f %F


Where I'd like or expect:

% printf '%s\n' '01-03-2004 foo' 'bar baz' | dateconv -ESi %d-%m-%Y -f %F
2004-03-01 foo bar

Or, ideally:

% printf '%s\n' '01-03-2004 foo' 'bar baz' | dateconv -ESi %d-%m-%Y -f %F
2004-03-01 foo bar

This is related to https://github.com/hroptatyr/dateutils/issues/138 insofar as I would like to exclude failures from my data set.

Earnestly avatar Feb 12 '22 15:02 Earnestly

Hi, thanks for the report. This was indeed an oversight. 49e5bc18e contains a proposal. I would like to keep -E's behaviour to print empty lines so that the result before and after the pipe show the same line count.

hroptatyr avatar Feb 14 '22 11:02 hroptatyr

What benefit would matching line counts have? Perhaps this is useful for someone, but as far as I can see this means sticking | awk NF after every use of it.

Earnestly avatar Feb 14 '22 14:02 Earnestly

To find out about lines that couldn't be converted. Otherwise, plug a dategrep beforehand to find lines with a given formatting first. If dateconv also did filtering then there would be no way to find out without more tools (nl, diff, etc.)

hroptatyr avatar Feb 15 '22 07:02 hroptatyr

That's a fair point even though it's not something I typically need as I tend to use pipelines as sieves. I can always regain this feature, but the loss of information could not be recovered.

Earnestly avatar Feb 15 '22 11:02 Earnestly