-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Allow DateTime and Dates.ISODateTimeFormat to use a trailing "Z" #23049
Comments
julia> Dates.ISODateTimeFormat is not ISO6801 compliant. It lacks the time zone part. ("+|-HH:MM" | "Z"). "2019-12-13T19:33:22.5093173+01:00" Since this issue is now open close to 2 years... someone should address it. See https://en.wikipedia.org/wiki/ISO_8601 |
Time zone support is added by TimeZones.jl. julia> using Dates, TimeZones
julia> ZonedDateTime("2019-12-13T19:33:22.509+01:00", dateformat"yyyy-mm-ddTHH:MM:SS.sssz")
2019-12-13T19:33:22.509+01:00 Support however isn't perfect as I think your exact example uses sub-millisecond precision which unfortunately isn't handled by |
Would it not be better to fix instead of adding? (extend Dates package, deprecate TimeZones package? https://github.com/JuliaLang/julia/blob/master/stdlib/Dates/src/io.jlExtend parse() and other functions to deal with (new) time zone field. https://github.com/JuliaLang/julia/blob/master/stdlib/Dates/src/accessors.jlAdd accessor for (new) time zone field "offset". https://github.com/JuliaLang/julia/blob/master/stdlib/Dates/src/adjusters.jltozulu()
totimezone()
Please note, that
So, tozulu() is redundant but maybe nice to have. https://github.com/JuliaLang/julia/blob/master/stdlib/Dates/src/types.jlAbstractTime now also needs to contract an offset (in minutes). function DateTime(...) needs another optional argument (offset). function DateTime(dt::Date, t::Time) needs another argument (offset). Gotchas:Use case 1: Create a DateTime in GMT+1, noon.
Use case 2: Create a Zulu noon.
totimezone(dt2,60) => "2019-01-01T13:00:00.0+01:00"
Depending on what user tries to do, this might be confusing. SummaryOther files in Dates package might be affected as well. Since there were no time zones before, old code should not break if default offset is ZULU (offset = 0). Except for code which tries to parse a compliant ISO6801 string and relies on it to fail to enter a special handling code path. |
It should be noted that there isn't anything special about Dates being a stdlib and TimeZones as a package. The Julia I'd start by using the existing support for time zones before attempting to reinvent it. |
I think we should add offset support to Dates (equivalent to the We can (and probably should) leave timezones themselves in the TimeZones.jl, since they can change very frequently. cc: @KristofferC |
On Julia v0.7 and v0.6, the ISODateTimeFormat doesn't like the trailing "Z".
I'm not sure whether it's officially a part of the ISO8601 standard to have the trailing "Z" (it looks like it might be, but I'd need to read the standard and you've got to buy a copy :)). But even if it isn't, it would be nice to accept it, since a lot of places use them for time stamps (e.g. YouTube).
The text was updated successfully, but these errors were encountered: