TimeZones.jl
TimeZones.jl copied to clipboard
Loading TimeZones changes behaviour of Dates.DateFormat with Error: Unable to parse date time.
I stumbled upon this behavior when adding TimeZones functionality to an existing programme. An reduced it to a minimal example.
using Dates
DateTime("2018-11-02T00:00:00Z", DateFormat("yyyy-mm-ddTHH:MM:SSZ"))
using TimeZones
DateTime("2018-11-02T00:00:00Z", DateFormat("yyyy-mm-ddTHH:MM:SSZ"))
The output is the following:
2018-11-02T00:00:00
ERROR: ArgumentError: Unable to parse date time. Expected directive DatePart(Z) at char 20
I know this behaviour is documented and not a bug (and I could solve it by adding "\" in front of Z). But for me it felt like a bug and I took me quite some time to find the reason for the error in my code.
I am not really sure what change to suggest or even if to suggest a change. But in my opinion, the change itself is quite subtle and maybe deserves a warning. I'm looking forward to hear your opinion on this behaviour and thanks for the great work on this package.
Thanks for the issue. I also agree it is unfortunate that this can catch people by surprise. One way to keep users from being surprised would be to emit a warning when running DateFormat("yyyy-mm-ddTHH:MM:SSZ")
that T
and Z
may be used as code characters by other packages and should be escaped.