jweir / elm-iso8601

Elm library to parse and convert ISO8601 times and dates
https://package.elm-lang.org/packages/jweir/elm-iso8601/latest
MIT License
15 stars 7 forks source link

fromPosix doesn't return the correct time? #12

Closed smucode closed 6 years ago

smucode commented 6 years ago

In the following example the time is 44 seconds off:

> time = Time.millisToPosix 2493072000001
Posix 2493072000001 : Time.Posix

> (ISO8601.fromPosix time |> ISO8601.toPosix) == time
False : Bool

> ISO8601.fromPosix time |> ISO8601.toPosix
Posix 2493072044001 : Time.Posix
jweir commented 6 years ago

Thank you very much.

The issue is around large ints and Elm and Javascript.

> 2493072000001 // 1000
-1801895296 : Int

The work around is to convert to a float and then round the result.

New version is up. Please test.