gpt4 book ai didi

timezone - 如何在 Julia 中使用超过 2038 年的时区日期?

转载 作者:行者123 更新时间:2023-12-01 12:25:11 26 4
gpt4 key购买 nike

我需要在 Julia 中使用超过 2038 年的日期。怎么做?显然,您不能在 2038 年之后的年份使用时区日期。

TimeZones.jl 的 md

https://github.com/JuliaTime/TimeZones.jl/blob/d997abb7398ca8514007d1cbc77a031f721c727b/docs/types.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 isinfeasible to determine a time zones transitions to infinity. Since2038-01-19T03:14:07 is the last DateTime that can be represented by anInt32 (Dates.unix2datetime(typemax(Int32))) it was decided that 2037would be the last year in which all transition dates are computed. Ifadditional transitions are known to exist after the last transitionthen a cutoff date is specified.

It is important to note that since we are taking about future timezone transitions and the rules dictating these transitions are subjectto change and may not be accurate. If you still want to work withfuture ZonedDateTime past the default cutoff you can re-compile theTimeZone 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

关于timezone - 如何在 Julia 中使用超过 2038 年的时区日期?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40554940/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com