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

标签 timezone julia

我需要在 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 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

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

相关文章:

sql - PostgreSQL:将间隔添加到不同时区的时间戳

parsing - 为什么 time.Parse 不使用时区?

multithreading - Julia 1.5.2并行启动随机数选择

julia - 每次启动 Julia 环境时运行 Julia 函数

julia - 如何在 Julia 中使用向量作为类型参数

timezone - 在 jq 中可靠地解析日期字符串

c# - 在数据库中存储时区信息的最佳方式是什么?

ruby-on-rails - 为什么Heroku使用服务器时间而不是Rails时区记录日志?

julia - 在Julia 1.0.2中查找功能

julia - 在 Julia GPU 代码中生成泊松分布随机数的正确方法?