TimeZones.jl icon indicating copy to clipboard operation
TimeZones.jl copied to clipboard

Provide user friendly exceptions with deprecated time zones

Open omus opened this issue 1 year ago • 1 comments

As discussed in #419 when a time zone becomes deprecated as "Europe/Amsterdam" was as of tzdata release 2022f they see the following error:

julia> using TimeZones

julia> tz"Europe/Amsterdam"
ERROR: LoadError: ArgumentError: The time zone "Europe/Amsterdam" is of class `TimeZones.Class(:LEGACY)` which is currently not allowed by the mask: `TimeZones.Class(:FIXED) | TimeZones.Class(:STANDARD)`
Stacktrace:
 [1] TimeZone(str::String, mask::TimeZones.Class)
   @ TimeZones ~/.julia/dev/TimeZones/src/types/timezone.jl:51
 [2] TimeZone(str::String)
   @ TimeZones ~/.julia/dev/TimeZones/src/types/timezone.jl:42
 [3] var"@tz_str"(__source__::LineNumberNode, __module__::Module, str::Any)
   @ TimeZones ~/.julia/dev/TimeZones/src/types/timezone.jl:72
in expression starting at REPL[17]:1

This error does not provide the user with the details of any possible replacement for the deprecated time zone. The backward region file contains this information and for 2022f it states that "Europe/Brussels" is the replacement for "Europe/Amsterdam". Providing this information to users would allow an easy upgrade path instead of having them rely on a legacy time zone via TimeZones("Europe/Amsterdam", TimeZones.Class(:LEGACY)) or choose an alternate time zone which may be incorrect.

omus avatar Sep 04 '24 15:09 omus

Deprecations are commonly included in minor version bumps for Julia packages. The difference here is that TimeZones.jl doesn't allow the use of legacy/deprecated time zones by default. I could see an argument to be made for tying the default TimeZone.Class with the --depwarn flag and having --depwarn=error be the only mode where TimeZone.Class(:LEGACY) is disallowed. – https://github.com/JuliaTime/TZJData.jl/issues/31#issuecomment-2341738128

omus avatar Sep 10 '24 18:09 omus