DateTimeA zone-aware date and time: an instant plus its time zone, so calendar components, DST, and offsets all come out right.
Read components with year / month / day / hour / … / weekday; shift by absolute time with +: / -: (Duration) or by calendar units with plusDays: / plusMonths: / … (DST- and end-of-month-aware); re-view the same instant elsewhere with inZone:. Prints and parses as RFC 9557 — RFC 3339 plus a [Zone] suffix. Comparison (<:, ==:) is by instant, regardless of zone.
var noon = DateTime.parse:'2024-01-01T12:00:00-05:00[America/New_York]' noon.weekday "* -> 'Monday' (noon.plusMonths:1).s "* -> 2024-02-01T12:00:00-05:00[America/New_York] (noon.inZone:(TimeZone.of:'Asia/Tokyo')).s "* -> 2024-01-02T02:00:00+09:00[Asia/Tokyo]
The zone-aware instant, as its RFC 9557 string ('…+09:00[Asia/Tokyo]') — lossless for Quoin (DateTime.parse: reads it back, zone and all). For bare RFC 3339 interop, serialize .timestamp instead.
The current date and time in the host's local time zone.
The current date and time in the given zone: DateTime.nowIn:(TimeZone.of:'Asia/Tokyo').
The current date and time in UTC.
Parse an RFC 9557 zoned datetime string — RFC 3339 plus a [Zone] suffix (throws a ValueError on anything else). The inverse of s.
(DateTime.parse:'2024-01-01T12:00:00-05:00[America/New_York]').year "* -> 2024
The DateTime shifted later by a Duration — absolute time, so adding 24 hours across a DST change moves the wall clock. For calendar arithmetic use plusDays: and friends. Leaving the representable range throws an ArithmeticError.
((DateTime.parse:'2024-01-01T12:00:00+00:00[UTC]') + (Duration.minutes:90)).s "* -> 2024-01-01T13:30:00+00:00[UTC]
With a Duration argument: the DateTime shifted earlier by that much (absolute time; the calendar-aware counterpart is minusDays: and friends).
((DateTime.parse:'2024-01-01T12:00:00+00:00[UTC]') - (Duration.minutes:90)).s "* -> 2024-01-01T10:30:00+00:00[UTC]
Whether the receiver names the earlier instant — compared by instant, so zones don't matter. Only <: is native; >: / <=: / >=: derive from it on Object.
Whether the argument is a DateTime naming the same instant — the zone is not compared, so noon UTC equals 7am New York. A non-DateTime argument is simply unequal.
(DateTime.parse:'2024-01-01T12:00:00+00:00[UTC]') == (DateTime.parse:'2024-01-01T07:00:00-05:00[America/New_York]') "* -> true
The civil calendar Date of this DateTime's local components (the zone-dependent view: the same instant is a different date in Tokyo and Honolulu).
(DateTime.parse:'2026-07-11T09:40:00+00:00[UTC]').date.s "* -> 2026-07-11
The day of the month, 1–31 (Integer).
The hour of the day, 0–23 (Integer).
The same instant viewed in another zone — only the local components change.
((DateTime.parse:'2024-01-01T12:00:00+00:00[UTC]').inZone:(TimeZone.of:'Asia/Tokyo')).s "* -> 2024-01-01T21:00:00+09:00[Asia/Tokyo]
The DateTime n calendar days earlier — plusDays: in reverse.
((DateTime.parse:'2024-01-01T12:00:00+00:00[UTC]').minusDays:1).s "* -> 2023-12-31T12:00:00+00:00[UTC]
The DateTime n calendar months earlier, clamping to the end of a shorter month (like plusMonths:).
The DateTime n calendar weeks earlier.
The DateTime n calendar years earlier.
The minute of the hour, 0–59 (Integer).
The month of the year, 1–12 (Integer).
The subsecond part in nanoseconds, 0–999999999 (Integer).
The DateTime n calendar days later. Calendar arithmetic keeps the wall-clock time, so a day across a DST change is not 24 absolute hours.
((DateTime.parse:'2024-11-03T00:00:00-04:00[America/New_York]').plusDays:1).s "* -> 2024-11-04T00:00:00-05:00[America/New_York]
The DateTime n calendar months later, clamping to the end of a shorter month.
((DateTime.parse:'2024-01-31T12:00:00+00:00[UTC]').plusMonths:1).s "* -> 2024-02-29T12:00:00+00:00[UTC]
The DateTime n calendar weeks later (DST-aware, like plusDays:).
The DateTime n calendar years later (Feb 29 clamps to Feb 28 in a non-leap year).
The RFC 9557 string: RFC 3339 plus an [IANA/Zone] suffix. Round-trips through DateTime.parse:.
(DateTime.parse:'2024-01-01T12:00:00-05:00[America/New_York]').s "* -> 2024-01-01T12:00:00-05:00[America/New_York]
The second of the minute, 0–59 (Integer).
The wall-clock Time of this DateTime's local components.
(DateTime.parse:'2026-07-11T09:40:00+00:00[UTC]').time.s "* -> 09:40:00
The TimeZone this DateTime is expressed in.
The underlying absolute instant, as a zone-less Timestamp.
(DateTime.parse:'2024-01-01T12:00:00-05:00[America/New_York]').timestamp.s "* -> 2024-01-01T17:00:00Z
The calendar Span from the receiver to the argument (negative when the argument is earlier), in years/months/days/hours/… — zone-aware, so a day across a DST change counts as one day. The absolute-time diff is -: (→ Duration).
((DateTime.parse:'2024-01-15T00:00:00+00:00[UTC]').until:(DateTime.parse:'2026-03-18T00:00:00+00:00[UTC]')).s "* -> 2y 2mo 3d
The English weekday name.
(DateTime.parse:'2024-01-01T12:00:00+00:00[UTC]').weekday "* -> 'Monday'
The calendar year (Integer), in this DateTime's own zone.