Elm Exactly
Results / elm-time /

TimeIssue7ZoneTransitionStartTest

Tags:elm19-bug

elm-0.19.1 failelm-0.19.2 failelm-0.19.3 faillamdera-1.5.0 fail

Issue: elm/time#7

A zone transition does not take effect at its own start minute.

<https://github.com/elm/time/issues/7>

With `customZone 0 [ { start = 120, offset = 60 } ]` (from 02:00 UTC the offset is +01:00), the
instant 02:00 UTC is 03:00 local time. Elm 0.19.1 (elm/time 1.0.0) looks for an era whose start is
`<` the time instead of `<=`, so it still uses offset 0 and gives 02:00.

Results

elm-0.19.1

failran in 54 ms
Missing pattern: at start: (3,0)
--- output ---
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets.
at start: (2,0)
one minute later: (3,1)

elm-0.19.2

failran in 49 ms
Missing pattern: at start: (3,0)
--- output ---
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.2/optimize for better performance and smaller assets.
at start: (2,0)
one minute later: (3,1)

elm-0.19.3

failran in 46 ms
Missing pattern: at start: (3,0)
--- output ---
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.3/optimize for better performance and smaller assets.
at start: (2,0)
one minute later: (3,1)

lamdera-1.5.0

failran in 41 ms
Missing pattern: at start: (3,0)
--- output ---
at start: (2,0)
one minute later: (3,1)

Discussions

Discuss this test·Search the discussions on GitHub

Discussions are on GitHub; one about this test has [t:elm-time/TimeIssue7ZoneTransitionStartTest] in its title.

Source

The -- CHECK: lines give the expected output.

module TimeIssue7ZoneTransitionStartTest exposing (main)
{-| A zone transition does not take effect at its own start minute.
<https://github.com/elm/time/issues/7>
With `customZone 0 [ { start = 120, offset = 60 } ]` (from 02:00 UTC the offset is +01:00), the
instant 02:00 UTC is 03:00 local time. Elm 0.19.1 (elm/time 1.0.0) looks for an era whose start is
`<` the time instead of `<=`, so it still uses offset 0 and gives 02:00.
-}
-- TAGS: elm19-bug
-- CHECK: at start: (3,0)
-- CHECK: one minute later: (3,1)
import Html exposing (text)
import Time
zone : Time.Zone
zone =
Time.customZone 0 [ { start = 120, offset = 60 } ]
{-| Returns the local hour and minute in `zone` of the instant `minutes` after the epoch.
-}
hm : Int -> ( Int, Int )
hm minutes =
let
t =
Time.millisToPosix (minutes * 60000)
in
( Time.toHour zone t, Time.toMinute zone t )
main =
let
_ =
Debug.log "at start" (hm 120)
_ =
Debug.log "one minute later" (hm 121)
in
text "done"