scls19fr / GPX.jl

A Julia GPX parser (ie reader) and creator (ie writer). GPX (GPS eXchange Format) is an XML based file format for GPS tracks.
MIT License
6 stars 6 forks source link

Can't parse time with milliseconds #7

Closed CMGeldenhuys closed 3 years ago

CMGeldenhuys commented 3 years ago

ZonedDateTime fails to parse the <time> tag if milliseconds are present. However, the millisecond field seems to be optional in the GPX Time/Date standard. Unfortunately, Dates.jl (and TimeZones.jl) does not support optional field arguments (See JuliaTime/TimeZones.jl/issues/83).

To following example illiustrates the issue:

julia> using Dates, TimeZones

julia> s = "2019-11-07T08:44:55.000Z"
"2019-11-07T08:44:55.000Z"

julia> parse(ZonedDateTime, s, dateformat"yyyy-mm-ddTHH:MM:SSzzz") # current implementation
ERROR: ArgumentError: Unable to parse date time. Expected directive DatePart(zzz) at char 20
Stacktrace: [...]

julia> parse(ZonedDateTime, s, dateformat"yyyy-mm-ddTHH:MM:SS.ssszzz") # preposed implementation
2019-11-07T08:44:55+00:00