timezone之如何在 Julia 中使用超过 2038 年的时区日期
我需要在 Julia 中使用超过 2038 年的日期。怎么做?显然,您不能在 2038 年之后的年份使用时区日期。
TimeZones.jl 的 md
针对不存在的链接页面给出以下解释:
“或者,当使用 2038 年以后的 future 日期时将导致错误:
julia> ZonedDateTime(2039, warsaw)
ERROR: TimeZone Europe/Warsaw does not handle dates on or after 2038-03-28T01:00:00 UTC
in call at ~/.julia/v0.4/TimeZones/src/timezones/types.jl:146
in ZonedDateTime at ~/.julia/v0.4/TimeZones/src/timezones/types.jl:260
时区可以在 2038 年之后使用[链接],但由于这些日期是 future 的日期,因此时区规则可能会发生变化并且不准确。”
请您参考如下方法:
这是正确的 link .
它说的地方:
Due to the internal representation of a VariableTimeZone it is infeasible to determine a time zones transitions to infinity. Since 2038-01-19T03:14:07 is the last DateTime that can be represented by an Int32 (Dates.unix2datetime(typemax(Int32))) it was decided that 2037 would be the last year in which all transition dates are computed. If additional transitions are known to exist after the last transition then a cutoff date is specified.
It is important to note that since we are taking about future time zone transitions and the rules dictating these transitions are subject to change and may not be accurate. If you still want to work with future ZonedDateTime past the default cutoff you can re-compile the TimeZone objects and specify the max_year keyword: *
*强调我的。
using TimeZones
TimeZones.Olson.compile(max_year=2200)
ZonedDateTime(DateTime(2100), TimeZone("Europe/Warsaw"))
>>> 2100-01-01T00:00:00+01:00
1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。