Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't parse a DateTime with optional milliseconds if there is anything after it #26962

Open
iamed2 opened this issue May 2, 2018 · 3 comments
Labels
domain:dates Dates, times, and the Dates stdlib module stdlib Julia's standard library

Comments

@iamed2
Copy link
Contributor

iamed2 commented May 2, 2018

Here are some things that work:

julia> parse(DateTime, "2014-01-03T12:12:12", dateformat"yyyy-mm-dd\THH:MM:SS.s")
2014-01-03T12:12:12

julia> parse(DateTime, "2014-01-03T12:12:12.12Z", dateformat"yyyy-mm-dd\THH:MM:SS.sZ")
2014-01-03T12:12:12.12

Here is a thing that doesn't work:

julia> parse(DateTime, "2014-01-03T12:12:12Z", dateformat"yyyy-mm-dd\THH:MM:SS.sZ")
ERROR: ArgumentError: Unable to parse date time. Expected directive Delim(.) at char 20
Stacktrace:
 [1] @generated body at /Users/ericdavies/repos/juliamaster/usr/share/julia/stdlib/v0.7/Dates/src/parse.jl:104 [inlined]
 [2] tryparsenext_core(::String, ::Int64, ::Int64, ::DateFormat{Symbol("yyyy-mm-dd\\THH:MM:SS.s "),Tuple{Dates.DatePart{'y'},Dates.Delim{Char,1},Dates.DatePart{'m'},Dates.Delim{Char,1},Dates.DatePart{'d'},Dates.Delim{Char,1},Dates.DatePart{'H'},Dates.Delim{Char,1},Dates.DatePart{'M'},Dates.Delim{Char,1},Dates.DatePart{'S'},Dates.Delim{Char,1},Dates.DatePart{'s'},Dates.Delim{Char,1}}}, ::Bool) at /Users/ericdavies/repos/juliamaster/usr/share/julia/stdlib/v0.7/Dates/src/parse.jl:40
 [3] @generated body at /Users/ericdavies/repos/juliamaster/usr/share/julia/stdlib/v0.7/Dates/src/parse.jl:150 [inlined]
 [4] tryparsenext_internal at /Users/ericdavies/repos/juliamaster/usr/share/julia/stdlib/v0.7/Dates/src/parse.jl:127 [inlined]
 [5] parse(::Type{DateTime}, ::String, ::DateFormat{Symbol("yyyy-mm-dd\\THH:MM:SS.s "),Tuple{Dates.DatePart{'y'},Dates.Delim{Char,1},Dates.DatePart{'m'},Dates.Delim{Char,1},Dates.DatePart{'d'},Dates.Delim{Char,1},Dates.DatePart{'H'},Dates.Delim{Char,1},Dates.DatePart{'M'},Dates.Delim{Char,1},Dates.DatePart{'S'},Dates.Delim{Char,1},Dates.DatePart{'s'},Dates.Delim{Char,1}}}) at /Users/ericdavies/repos/juliamaster/usr/share/julia/stdlib/v0.7/Dates/src/parse.jl:282
 [6] top-level scope

This makes it impossible to parse a DateTime with optional milliseconds if there is anything after it.

@omus omus added the domain:dates Dates, times, and the Dates stdlib module label May 2, 2018
@omus
Copy link
Member

omus commented May 2, 2018

Related: JuliaTime/TimeZones.jl#83

@cormullion
Copy link
Contributor

related: #23049

@alhirzel
Copy link
Contributor

alhirzel commented Jun 1, 2020

see also: scls19fr/KMLTracks.jl#5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:dates Dates, times, and the Dates stdlib module stdlib Julia's standard library
Projects
None yet
Development

No branches or pull requests

5 participants