dateutils icon indicating copy to clipboard operation
dateutils copied to clipboard

confusing month and minute in dateadd

Open ghost opened this issue 7 years ago • 4 comments

Hey,

dateadd seems to use minute as month:

$ dateadd -i %y%m%d 000000 +1m  -f %m%d
0100
$ dateadd -i %y%m%d 000000 +1mo  -f %m%d
0100

What's the problem here?

Thank you.

ghost avatar May 11 '18 11:05 ghost

Hey, thanks for the report. That's a historical artefact. Back in the days there were two sets of tools, one for handling dates only (which treated the m suffix as months) and one for date/times (which used mo for months and m for minutes).

When we married the two sets, as a compromise and for backward compatibility, we decided to treat the m suffix in dates-only input as months. Whereas date/time input will treat mo as months and m as minutes.

hroptatyr avatar May 11 '18 13:05 hroptatyr

Ah okay. That makes sense. But you should point this out in the man-page. Thank you.

ghost avatar May 11 '18 13:05 ghost

Hey, in the spirit of precise-is-better-than-concise I decided to follow your suggestion and drop the compatibility. And, of course, document the change this time.

As mentioned in the commit message this change tidies up the (admittedly stupid) handling of mixed input, i.e. some lines of dates and some lines of date/times, all while adding 1m. Before I expected people to separate their input into either dates, or times, or date/times.

Thanks again for the report.

hroptatyr avatar May 14 '18 06:05 hroptatyr

Hey, I think, this is a good decision. From my point of view it was more like a bug, than like a feature, this is why I reported this. Thank you, very much.

ghost avatar May 14 '18 08:05 ghost