Skip to content

Commit

Permalink
Accept dates with no ending Z
Browse files Browse the repository at this point in the history
  • Loading branch information
FabienHenon committed Jan 24, 2019
1 parent 784602a commit 618f6ca
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Iso8601.elm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions tests/Example.elm
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 618f6ca

Please sign in to comment.