-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Description
Currently DateTime
is completely time-zone unaware: this simplicity was intentional (as described by @quinnj in #49700 (comment)), with additional functionality pushed to TimeZones.jl.
The problem is that many packages skip time zone support altogether, or implement it in inconsistent ways: for example, now()
returns a local DateTime
by default, whereas TOML.jl treats all DateTime
s as UTC.
Even packages which aren't in the stdlib are reluctant to use TimeZones.jl, resulting in bugs or less-than-useful information:
- Scratch.jl prints local times as UTC
- PkgServer.jl logs output in the local time
- GitHub.jl even defines
chopz
to get rid of the pesky trailing Z
What I would like to propose is to add basic UTC and UTC + offset support into stdlib (basically functionality which doesn't require looking up a timezone database). This would be sufficient to fully support the TOML datetime and many other applications.
I was thinking something like the following
struct DateTimeZoned{TZ<:TimeZone} <: AbstractDateTime
instant::UTInstant{Millisecond}
zone::TZ
end
We already have UTC <: TimeZone
defined, so we could also define
struct UTCOffset <: TimeZone
offset::Millisecond # or could use Minute?
end
Similarly we could expand the datetime""
macro to support the Z
(which would return a DateTimeZoned{UTC}
and +00:00
suffixes (which would return a DateTimeZoned{UTCOffset}
.
Like our current DateTime
, we would continue to ignore leap seconds (as basically every other piece of software does).
This would fix the following issues: