-
Notifications
You must be signed in to change notification settings - Fork 52
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
ZonedDateTime
can't parse it's own output
#83
Comments
It's definite possible to get it to parse the output. Unfortunately the output only shows the UTC offset for that specific timestamp which means that parsing it will result a loss of information since we would have to parse the string as a |
The output is actually fine with me. My concern is more the parsing. In Base, we hack the ISODateTime parsing to make the |
Although it does say
so maybe in parsing of various components, we should always allow |
cc also @quinnj |
I'm following along :) |
The DateFormat specification could use a re-think. It would be nice if when parsing you could state a section was optional. Something like |
I don't think I actually mind |
As for letters, there's always |
Mostly the optional specifiers for parsing would be useful. |
@rofinn just ran into this one: julia> ZonedDateTime("2017-01-28T11:59:59+00:00")
ERROR: ArgumentError: Unable to parse date time. Expected directive Delim(.) at char 20 |
I ran into the same problem as well (I ended up adding a silly |
Something related would be to make sure that |
Related: JuliaLang/julia#29909 |
Excuse my ignorance, but is |
You correctly save the instant in time but you lose information for, e.g., date math. |
This is still a problem: julia> ZonedDateTime("2017-04-14 10:58:40-04", dateformat"YYYY-mm-dd HH:MM:SS.ssszz")
ERROR: ArgumentError: Unable to parse string "2017-04-14 10:58:40-04" using format dateformat"YYYY-mm-dd HH:MM:SS.ssszz". Unable to parse date time. Expected directive Delim(.) at char 20
Stacktrace:
[1] macro expansion at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.1/Dates/src/parse.jl:104 [inlined]
[2] tryparsenext_core(::String, ::Int64, ::Int64, ::DateFormat{Symbol("YYYY-mm-dd HH:MM:SS.ssszz"),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.DatePart{'z'}}}, ::Bool) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.1/Dates/src/parse.jl:40
[3] macro expansion at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.1/Dates/src/parse.jl:150 [inlined]
[4] tryparsenext_internal at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.1/Dates/src/parse.jl:127 [inlined]
[5] parse at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.1/Dates/src/parse.jl:282 [inlined]
[6] ZonedDateTime(::String, ::DateFormat{Symbol("YYYY-mm-dd HH:MM:SS.ssszz"),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.DatePart{'z'}}}) at /home/glynch/.julia/packages/TimeZones/Z0kpK/src/parse.jl:85
[7] top-level scope at none:0 |
Your particular example will always be an issue. If you are passing in a As a stop gap measure I'm planning on supporting: parse(ZonedDateTime, str) which would handle both I'm also doing so research into different date parsing/formatting syntaxes to see what alternatives I can find and introduce into the Dates stdlib. |
Hi @omus , we just came across this too: julia> str = string(ZonedDateTime("2020-08-12T12:00:00.000+00:00"))
"2020-08-12T12:00:00+00:00"
julia> parse(ZonedDateTime, str)
ERROR: ArgumentError: Unable to parse date time. Expected directive Delim(.) at char 20
Stacktrace:
[1] macro expansion at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.5/Dates/src/parse.jl:104 [inlined]
[2] tryparsenext_core(::String, ::Int64, ::Int64, ::DateFormat{Symbol("yyyy-mm-ddTHH:MM:SS.ssszzz"),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.DatePart{'z'}}}, ::Bool) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.5/Dates/src/parse.jl:38
[3] macro expansion at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.5/Dates/src/parse.jl:150 [inlined]
[4] tryparsenext_internal at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.5/Dates/src/parse.jl:125 [inlined]
[5] parse(::Type{ZonedDateTime}, ::String, ::DateFormat{Symbol("yyyy-mm-ddTHH:MM:SS.ssszzz"),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.DatePart{'z'}}}) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.5/Dates/src/parse.jl:282
[6] parse(::Type{ZonedDateTime}, ::String) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.5/Dates/src/parse.jl:281
[7] top-level scope at REPL[13]:1
Ref the Time Standard: |
Is there plans to fix this? I was going to open an issue as I ran to this exact problem. Shouldn't |
The loss of information did not occur at parse time, it occured when converting the |
Also note that while this |
This seems unfortunate:
The text was updated successfully, but these errors were encountered: