hroptatyr / dateutils

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

Insufficient date validation in datediff #163

Open rdiez opened 3 weeks ago

rdiez commented 3 weeks ago

It is difficult to use datediff in a robust manner. For example, dates that are obviously invalid are still accepted:

$ dateutils.ddiff  2024-1x-k3  2024-01-02
2

That happens even if a particular input format is specified:

$ dateutils.ddiff  --input-format="%d/%m/%Y"  2024-1x-k3  31/12/2024
366

It looks like datediff is applying the input formats only to the 2nd date specified, because this fails properly:

$ dateutils.ddiff  --input-format="%d/%m/%Y"  2024-1x-k2  2024-3x-k4
ddiff: cannot make sense of `2024-3x-k4' using the given input formats

I am using the datediff 0.4.5 which comes with Ubuntu 22.04.

hroptatyr commented 3 weeks ago

Hi, thanks for the report. A fix is in 9c592942f.

rdiez commented 3 weeks ago

OK, thanks for the quick fix.