hroptatyr / dateutils

nifty command line date and time utilities; fast date calculations and conversion in the shell
http://www.fresse.org/dateutils/
Other
616 stars 42 forks source link

confusing month and minute in dateadd #76

Open ghost opened 6 years ago

ghost commented 6 years ago

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.

hroptatyr commented 6 years ago

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.

ghost commented 6 years ago

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

hroptatyr commented 6 years ago

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.

ghost commented 6 years ago

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.