hroptatyr / dateutils

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

12 AM or 12 PM not understood correctly with %I and %p format #71

Closed oroussel closed 6 years ago

oroussel commented 6 years ago

Hello,

It seems dateconv does a wrong conversion if the hour number is 12, and using a 12-hour clock, when using %I and %p format. See eg. the table on the right of https://en.wikipedia.org/wiki/12-hour_clock.

$ dateconv -V
dateconv 0.4.2
$ dateconv -i "%I:%M:%S %p" "11:59:59 AM"
11:59:59       # Correct
$ dateconv -i "%I:%M:%S %p" "12:00:01 PM"
00:00:01       # Incorrect, should be 12:00:01
$ dateconv -i "%I:%M:%S %p" "11:59:59 PM"
23:59:59        # Correct
$ dateconv -i "%I:%M:%S %p" "12:00:01 AM"
12:00:01       # Incorrect, should be 00:00:01
hroptatyr commented 6 years ago

Thanks for the bug report, Olivier. Well spotted. A fix is in master now (a75f2525).

oroussel commented 6 years ago

Thanks for the quick feedback, and the quick fix :-). Your tool is really useful!