[racket] find-seconds and date/time ambiguities

From: Dan Thedens (dthedens at gmail.com)
Date: Wed Jun 19 16:42:29 EDT 2013

When the switch from daylight to standard time occurs, there are a set
of date/times that occur twice (once in daylight, then again in
standard time, 01:00:00 to 01:59:59 in my USA Central time zone) and
are ambiguous when specified without timezone and DST information such
as with find-seconds.

Is the behavior of find-seconds considered to be unspecified in these
cases?  The time at which it switches from a value reflecting daylight
time to one for standard time seems to be somewhat arbitrary.  This is
running 32-bit Racket 5.3.4 on Ubuntu 10.04 LTS built from source (my
primary machine).

;;; For Nov 3, 2013, changes at 01:41:04
(find-seconds 3 41 1 3 11 2013) -> 1383460863
(seconds->date 1383460863) -> (date* 3 41 1 3 11 2013 0 306 #t -18000 0 "CDT")

(find-seconds 4 41 1 3 11 2013) -> 1383464464
(seconds->date 1383464464) -> (date* 4 41 1 3 11 2013 0 306 #f -21600 0 "CST")

;;; For Nov 2, 2014, changes at 01:32:32
(find-seconds 31 32 1 2 11 2014) -> 1414909951
(seconds->date 1414909951) -> (date* 31 32 1 2 11 2014 0 305 #t -18000 0 "CDT")

(find-seconds 32 32 1 2 11 2014) -> 1414913552
(seconds->date 1414913552) -> (date* 32 32 1 2 11 2014 0 305 #f -21600 0 "CST")

;;; For Nov 1, 2015, changes at 01:32:15
(find-seconds 14 32 1 1 11 2015) -> 1446359534
(seconds->date 1446359534) -> (date* 14 32 1 1 11 2015 0 304 #t -18000 0 "CDT")

(find-seconds 15 32 1 1 11 2015) -> 1446363135
(seconds->date 1446363135) -> (date* 15 32 1 1 11 2015 0 304 #f -21600 0 "CST")

;;; For Nov 6, 2016, changes at 01:38:56
(find-seconds 55 38 1 6 11 2016) -> 1478414335
(seconds->date 1478414335) -> (date* 55 38 1 6 11 2016 0 310 #t -18000 0 "CDT")

(find-seconds 56 38 1 6 11 2016) -> 1478417936
(seconds->date 1478417936) -> (date* 56 38 1 6 11 2016 0 310 #f -21600 0 "CST")

This also leads to some times that don't 'invert' when using
seconds->date and date->seconds.

(date->seconds (seconds->date 1383464463)) -> 1383460863
(date->seconds (seconds->date 1414913551)) -> 1414909951
(date->seconds (seconds->date 1446363134)) -> 1446359534
(date->seconds (seconds->date 1478417935)) -> 1478414335

I see the same effect on a fresh install of Racket 5.3.5 on Windows 7,
but at different times (these are the first times that find-seconds
yields a standard time result).

For Nov 3, 2013, 01:02:47
(find-seconds 46 2 1 3 11 2013) -> 1383458566
(find-seconds 47 2 1 3 11 2013) -> 1383462167

For Nov 2, 2014, 01:22:31
(find-seconds 30 22 1 2 11 2014) -> 1414909350
(find-seconds 31 22 1 2 11 2014) -> 1414912951

For Nov 1, 2015, 01:37:38
For Nov 6, 2016, 01:01:28

Thanks for any clarifications,
Dan Thedens

Posted on the users mailing list.