jweir / elm-iso8601

Elm library to parse and convert ISO8601 times and dates

Home Page:https://package.elm-lang.org/packages/jweir/elm-iso8601/latest

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Invalid date being returned

liamcurry opened this issue · comments

I'm getting an invalid date when I try to convert 1459530703000 into an ISO8601 string.

I'd expect it to be converted to:

2016-04-01T17:11:43Z

But instead it's being converted to:

2016-03-32T17:11:43Z

Here's an example from elm-repl:

> import ISO8601
> time = 1459530703 * 1000
1459530703000 : number
> time |> ISO8601.fromTime
{ year = 2016, month = 3, day = 32, hour = 17, minute = 11, second = 43, millisecond = 0, offset = (0,0) } : ISO8601.Time
> time |> ISO8601.fromTime |> ISO8601.toString
"2016-03-32T17:11:43Z" : String
> import Date
> time |> toFloat |> Date.fromTime |> Date.day
1 : Int

As you can see Date.fromTime gets the right day, so I assume something strange is going on with the offset conversions.

Thank very much. 32 days in March looks a bit fishy.

Indeed there was a rounding issue at the transition of months. A patched version has been released.

Awesome, thanks!