Hi Julien,
You wrote:
> We found this very suspect behavior:
>
> $ date --date '20180325 02:58:00'
> date: invalid date `20180325 02:58:00'
>
> but for the previous day it works...:
>
> $ date --date '20180323 02:58:00'
> Fri Mar 23 02:58:00 CET 2018
>
> Is it a bug?
>
> Adding -u or setting TZ seems a workaround.
>
> Tested with version 8.28 on Ubuntu 18.04.4 LTS
> and also with version 8.13 on Debian GNU/Linux 7
This report was from 5 years ago, so I assume you found the answer. If
not, then apologies for the late response.
The output of this command explains the behavior that you see:
$ zdump -v Europe/Paris | grep 2018 | head -n 2
Europe/Paris Sun Mar 25 00:59:59 2018 UT = Sun Mar 25 01:59:59 2018 CET
isdst=0 gmtoff=3600
Europe/Paris Sun Mar 25 01:00:00 2018 UT = Sun Mar 25 03:00:00 2018 CEST
isdst=1 gmtoff=7200
So we can see that one second after 01:59:59 on March 25th the time
changes to 03:00:00 instead of 02:00:00 because of daylight savings
time.
The --debug option attempts to make this case a bit more clear, so you
do not need to reference the output of 'zdump':
$ TZ=Europe/Paris date --debug --date '20180325 02:58:00'
date: parsed number part: (Y-M-D) 2018-03-25
date: parsed time part: 02:58:00
date: input timezone: TZ="Europe/Paris" environment value
date: using specified time as starting value: '02:58:00'
date: error: invalid date/time value:
date: user provided time: '(Y-M-D) 2018-03-25 02:58:00'
date: normalized time: '(Y-M-D) 2018-03-25 03:58:00'
date: --
date: possible reasons:
date: nonexistent due to daylight-saving time;
date: invalid day/month combination;
date: missing timezone
date: invalid date ‘20180325 02:58:00’
Thanks,
Collin