You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A colleague and I were baffled today when some machine learning training code crashed with a NonExistentTimeError. Here's an MWE:
julia>ZonedDateTime(DateTime(1982,1,1,0), tz"Europe/Gibraltar")
ERROR: NonExistentTimeError: Local DateTime 1982-01-01T00:00:00 does not exist within Europe/Gibraltar
Stacktrace:
[1] (::TimeZones.var"#construct#8"{DateTime, VariableTimeZone})(T::Type{Local})
@ TimeZones C:\Users\niclas\.julia\packages\TimeZones\V28u7\src\types\zoneddatetime.jl:44
[2] #ZonedDateTime#7
@ C:\Users\niclas\.julia\packages\TimeZones\V28u7\src\types\zoneddatetime.jl:50 [inlined]
[3] ZonedDateTime(dt::DateTime, tz::VariableTimeZone)
@ TimeZones C:\Users\niclas\.julia\packages\TimeZones\V28u7\src\types\zoneddatetime.jl:35
[4] top-level scope
@ REPL[90]:1
Constructing the same ZonedDateTime worked just fine for 1980 and 1981, or alternatively for Jan 2 of 1982 instead of Jan 1. I'm sure the explanation is obvious for the package devs but it certainly wasn't for us. Apparently Gibraltar switched time zones in 1982:
So that particular hour of that year of that time zone doesn't exist, and the error is correct. But it's still inscrutable for those inexperienced with working with time zones. The more common source of this error is the transition to/from daylight savings time, and I noticed there is a hint for that case in the help string:
help?> NonExistentTimeError
search: NonExistentTimeError
NonExistentTimeError(local_datetime, timezone)
The provided local datetime is does not exist within the specified timezone. Typically occurs on daylight saving time transitions which "spring forward" causing an hour long period to be skipped.
But it's not obvious either that you could get that hint from the docs of the error constructor function.
Proposal
I suggest making two small changes. First, add a hint pointer in the error message for NonExistentTimeError, so something like this:
ERROR: NonExistentTimeError: Local DateTime 1982-01-01T00:00:00 does not exist within Europe/Gibraltar.
Type ?NonExistentTimeError for some possible explanations.
Second, expand the hints in that docstring:
NonExistentTimeError(local_datetime, timezone)
The provided local datetime does not exist within the specified timezone. Typically occurs on daylight saving time transitions which "spring forward" causing an hour long period to be skipped, or in rare instances when a region permanently switches time zones.
(Also note there is a superfluous "is" in the original string.) Similar changes should also be made to AmbiguousTimeError. Are there other possible explanations that could be appended here?
The text was updated successfully, but these errors were encountered:
A colleague and I were baffled today when some machine learning training code crashed with a NonExistentTimeError. Here's an MWE:
Constructing the same ZonedDateTime worked just fine for 1980 and 1981, or alternatively for Jan 2 of 1982 instead of Jan 1. I'm sure the explanation is obvious for the package devs but it certainly wasn't for us. Apparently Gibraltar switched time zones in 1982:
https://en.wikipedia.org/wiki/Time_in_Gibraltar
So that particular hour of that year of that time zone doesn't exist, and the error is correct. But it's still inscrutable for those inexperienced with working with time zones. The more common source of this error is the transition to/from daylight savings time, and I noticed there is a hint for that case in the help string:
But it's not obvious either that you could get that hint from the docs of the error constructor function.
Proposal
I suggest making two small changes. First, add a hint pointer in the error message for NonExistentTimeError, so something like this:
Second, expand the hints in that docstring:
(Also note there is a superfluous "is" in the original string.) Similar changes should also be made to AmbiguousTimeError. Are there other possible explanations that could be appended here?
The text was updated successfully, but these errors were encountered: