time icon indicating copy to clipboard operation
time copied to clipboard

Zone transitions should take effect on their start times

Open justinmimbs opened this issue 7 years ago • 2 comments

For Posix times on the minute of a Zone transition's start time, an older offset is used for the local adjustment, instead of the new offset as expected.

The offset search looks for a transition time < the POSIX time, but it should look for one <= the POSIX time.

Here's an SSCCE, where the custom zone transitions at 2:00 UTC to the offset +01, so the local clocks would read 3:00 at that time.

import Time

transition =
    { start = 2 * 60, offset = 60 }

Time.toHour
    (Time.customZone 0 [ transition ])
    (Time.millisToPosix (transition.start * 60000))
    == 2
    
-- expected 3

Also, here's an Ellie that makes the example a little more visual.

justinmimbs avatar Sep 14 '18 20:09 justinmimbs

[ ( "01:59", start - 1 )
, ( "03:00", start )
, ( "03:01", start + 1 )
]

It looks like you have a mistake in your Ellie, because 03:00 - 1 /= 1:59, but rather 02:59. Am I missing something?

gyzerok avatar Sep 17 '18 12:09 gyzerok

Here is more info about the expected clock times for those three minutes:

UTC   | America/New_York
----- | ---------------------------------------
06:59 | 01:59 Eastern Standard Time (UTC-05:00)
07:00 | 03:00 Eastern Daylight Time (UTC-04:00)
07:01 | 03:01 Eastern Daylight Time (UTC-04:00)

The issue in elm/time is that, for the minute of any transition time (like the middle line above), it chooses the previous offset instead of the new offset (returning 02:00 instead of 03:00 in this example). Perhaps adding zone names would improve the Ellie example: https://ellie-app.com/3ncbw7mzg25a1

justinmimbs avatar Sep 17 '18 15:09 justinmimbs