Ruder Laplace <ruder.em...@gmail.com> wrote:
> Greetings,
> 
> I think I catched a bug related to the day-light saving gap:
> *uname -a ; date ; date -d "2020/06/01 10:00:00 +1 hours"*
> Linux ******** 4.19.0-8-amd64 #1 SMP Debian 4.19.98-1 (2020-01-26) x86_64
> GNU/Linux
> mié nov 25 10:30:29 CET 2020
> lun jun  1 *12*:00:00 CEST 2020
> 
> As far as I think it should work, the expected result should be: lun jun 1
> *11*:00:00 CEST 2020
> "One hour after 10" is 11, not 12.


You can check how date interprets your string using --debug:

$ date -d "2020/06/01 11:00:00 +1 hour" --debug 
date: warning: value 2020 has 4 digits. Assuming YYYY/MM/DD
date: parsed date part: (Y-M-D) 2020-06-01
date: parsed time part: 11:00:00 UTC+01
date: parsed relative part: +1 hour(s)
date: input timezone: parsed date/time string (+01)
date: using specified time as starting value: '11:00:00'
date: starting date/time: '(Y-M-D) 2020-06-01 11:00:00 TZ=+01'
date: '(Y-M-D) 2020-06-01 11:00:00 TZ=+01' = 1591005600 epoch-seconds
date: after time adjustment (+1 hours, +0 minutes, +0 seconds, +0 ns),
date:     new time = 1591009200 epoch-seconds
date: timezone: system default
date: final: 1591009200.000000000 (epoch-seconds)
date: final: (Y-M-D) 2020-06-01 11:00:00 (UTC)
date: final: (Y-M-D) 2020-06-01 13:00:00 (UTC+02)
Mo 1. Jun 13:00:00 CEST 2020


As you can see, it assumes that the "+1" indicates the timezone, which
is 1 hour behind your local zone, thus 11:00 there would actually be 12:00
in your time zone. The "hour" alone is then used as a +1 hour adjustment,
resulting in 13:00 CEST. Commands that work as you expected:

$ date -d "2020/06/01 11:00:00 1 hour" --debug
$ date -d "2020/06/01 11:00:00 +1 +1 hour" --debug
$ date -d "2020/06/01 11:00:00 CEST +1 hour" --debug
$ date -d "+1 hour 2020/06/01 11:00:00" --debug

rainer



Reply via email to