rtfeldman / elm-iso8601-date-strings

Convert between ISO-8601 date strings and Time.Posix
https://package.elm-lang.org/packages/rtfeldman/elm-iso8601-date-strings/latest
BSD 3-Clause "New" or "Revised" License
34 stars 21 forks source link

Make fraction of second (SSS) optional in `toTime` parser #5

Closed MethodGrab closed 6 years ago

MethodGrab commented 6 years ago

In our codebase we have ISO date strings without the fraction of second (SSS). Various documents seem to indicate that the fraction of second can be optional so both of these should be valid:

Iso8601.toTime "2018-01-01T12:00:00.000Z"
Iso8601.toTime "2018-01-01T12:00:00Z"

This PR updates the toTime parser to succeed with and without a fraction of second.

If necessary for a particular application, the standard supports the addition of a decimal fraction to the smallest time value in the representation. -- https://en.wikipedia.org/wiki/ISO_8601#General_principles

The brackets indicate that the fraction of seconds component is optional. -- https://docs.microsoft.com/en-us/previous-versions/sql/sql-server-2005/ms190977(v=sql.90)

rtfeldman commented 6 years ago

Thanks @MethodGrab!