From 618f6cabd5ba2a71ebfe6b195bed0c18e8891b2b Mon Sep 17 00:00:00 2001 From: Fabien Henon Date: Thu, 24 Jan 2019 16:29:25 +0100 Subject: [PATCH] Accept dates with no ending Z --- src/Iso8601.elm | 4 ++++ tests/Example.elm | 12 ++++++++++++ 2 files changed, 16 insertions(+) diff --git a/src/Iso8601.elm b/src/Iso8601.elm index 006c2c8..4d41fd9 100644 --- a/src/Iso8601.elm +++ b/src/Iso8601.elm @@ -334,6 +334,10 @@ iso8601 = |= paddedInt 2 |. symbol ":" |= paddedInt 2 + + -- No "Z" is valid + , succeed 0 + |. end ] , succeed (fromParts datePart 0 0 0 0 0) |. end diff --git a/tests/Example.elm b/tests/Example.elm index b483fda..7a51954 100644 --- a/tests/Example.elm +++ b/tests/Example.elm @@ -30,6 +30,18 @@ knownValues = \_ -> Iso8601.toTime "2012-11-12T00:00:00+01:00" |> Expect.equal (Ok (Time.millisToPosix 1352674800000)) + , test "toTime \"2012-11-12T00:00:00Z\" gives me 1352678400000" <| + \_ -> + Iso8601.toTime "2012-11-12T00:00:00Z" + |> Expect.equal (Ok (Time.millisToPosix 1352678400000)) + , test "toTime \"2012-11-12T00:00:00\" gives me 1352678400000" <| + \_ -> + Iso8601.toTime "2012-11-12T00:00:00" + |> Expect.equal (Ok (Time.millisToPosix 1352678400000)) + , test "Invalid UTC offset don't parse" <| + \_ -> + Iso8601.toTime "2012-11-12T00:00:00BAD" + |> Expect.err , test "-5:00 is an invalid UTC offset (should be -05:00)" <| \_ -> Iso8601.toTime "2012-04-01T00:00:00-5:00"