Sunday, August 23, 2020

[qdexovay] Daylight saving time in GNU date

Here is first time 1:30 AM happened on the morning of Daylight Saving Time ending in 2019 in Chicago:

bash$ TZ=posix/America/Chicago date --date=@1572762600
Sun Nov 3 01:30:00 CDT 2019

bash$ TZ=posix/America/Chicago date --date=@1572762600 --iso=minute
2019-11-03T01:30-05:00

After "fall back", here is the second time 1:30 AM happened, one hour later (confusingly a permutation of the digits of Unix time):

bash$ TZ=posix/America/Chicago date --date=@1572766200
Sun Nov 3 01:30:00 CST 2019

bash$ TZ=posix/America/Chicago date --date=@1572766200 --iso=minute
2019-11-03T01:30-06:00

If we omit the timezone suffix (e.g., -05:00 or -06:00), the parser chooses the first 1:30.  Why?

bash$ TZ=posix/America/Chicago date --debug --date=2019-11-03T01:30
date: parsed datetime part: (Y-M-D) 2019-11-03 01:30:00
date: input timezone: TZ="posix/America/Chicago" environment value
date: using specified time as starting value: '01:30:00'
date: starting date/time: '(Y-M-D) 2019-11-03 01:30:00'
date: '(Y-M-D) 2019-11-03 01:30:00' = 1572762600 epoch-seconds
date: timezone: TZ="posix/America/Chicago" environment value
date: final: 1572762600.000000000 (epoch-seconds)
date: final: (Y-M-D) 2019-11-03 06:30:00 (UTC)
date: final: (Y-M-D) 2019-11-03 01:30:00 (UTC-05)
Sun Nov 3 01:30:00 CDT 2019

Perhaps it should warn if the time is ambiguous.  But determining whether a given time is ambiguous seems difficult.

No comments :