Skip to content

ZonedDateTime

[Source]

A UTC moment plus zone context (an IANA zone OR a fixed offset).

Storage: POSIX (sec, nsec) UTC + zone name (or "" for Offset mode) + resolved Observation (local fields, offset, abbrev, isdst).

REF capability. Allocate once and reuse via reset_to, to_timezone_in_place, etc. For cross-actor sharing, convert via to_posix() + zone_name() (or offset_sec() when in Offset mode) and reconstruct in the receiver actor.

Construction patterns

ZonedDateTime.now()                                   // UTC
ZonedDateTime.now_in_zone("America/Los_Angeles")?     // IANA
ZonedDateTime.now_at_offset(-7 * 3600)                // fixed offset
ZonedDateTime.from_posix((sec, nsec))                 // reconstruct UTC
ZonedDateTime.from_posix_in_zone((sec, nsec), name)?
ZonedDateTime.from_posix_at_offset((sec, nsec), offset_sec)
class ref ZonedDateTime

Constructors

now

[Source]

Wall-clock now, in UTC.

new ref now()
: ZonedDateTime ref^

Returns


now_in_zone

[Source]

Wall-clock now, in the specified IANA zone. Errors if the zone isn't in the bundled tzdata (use try_zone(name) on an existing ZDT for richer error info).

new ref now_in_zone(
  name: String val)
: ZonedDateTime ref^ ?

Parameters

Returns


now_at_offset

[Source]

Wall-clock now, at a fixed numeric offset (not an IANA zone).

new ref now_at_offset(
  offset_sec': I32 val)
: ZonedDateTime ref^

Parameters

  • offset_sec': I32 val

Returns


from_posix

[Source]

Reconstruct a UTC ZonedDateTime from a POSIX tuple.

new ref from_posix(
  p: (I64 val , I64 val))
: ZonedDateTime ref^

Parameters

Returns


from_posix_in_zone

[Source]

Construct a ZonedDateTime in an IANA zone from a POSIX tuple.

new ref from_posix_in_zone(
  p: (I64 val , I64 val),
  name: String val)
: ZonedDateTime ref^ ?

Parameters

Returns


from_posix_at_offset

[Source]

Construct a ZonedDateTime at a fixed offset from a POSIX tuple.

new ref from_posix_at_offset(
  p: (I64 val , I64 val),
  offset_sec': I32 val)
: ZonedDateTime ref^

Parameters

  • p: (I64 val , I64 val)
  • offset_sec': I32 val

Returns


Public Functions

reset_to

[Source]

Mutate to represent a different UTC instant in the same zone (or offset). For Zone mode, re-resolves against the bundled tzdata — may fail if the new instant falls outside coverage, in which case self is left unchanged.

fun ref reset_to(
  p: (I64 val , I64 val))
: (None val | TzLookupError)

Parameters

Returns


to_timezone_in_place

[Source]

Mutate to represent the same UTC instant in a different IANA zone. Returns ZoneNotFound or OutOfCoverage on failure; self is left unchanged on error.

fun ref to_timezone_in_place(
  name: String val)
: (None val | TzLookupError)

Parameters

Returns


reset_at_offset

[Source]

Mutate to a UTC instant at a fixed offset, switching this ZDT to Offset mode. Symmetric with from_posix_at_offset but reuses self — no allocation.

fun ref reset_at_offset(
  p: (I64 val , I64 val),
  offset_sec': I32 val)
: None val

Parameters

  • p: (I64 val , I64 val)
  • offset_sec': I32 val

Returns


reset_in_zone

[Source]

Mutate to a UTC instant in an IANA zone, switching this ZDT to Zone mode. Symmetric with from_posix_in_zone; self is left unchanged on error.

fun ref reset_in_zone(
  p: (I64 val , I64 val),
  name: String val)
: (None val | TzLookupError)

Parameters

Returns


to_timezone

[Source]

Return a NEW ZonedDateTime representing the same UTC instant in a different IANA zone. Allocates one heap object on success.

fun box to_timezone(
  name: String val)
: (ZonedDateTime iso^ | TzLookupError)

Parameters

Returns


to_posix

[Source]

fun box to_posix()
: (I64 val , I64 val)

Returns


kind

[Source]

fun box kind()
: ZonedKind

Returns


zone_name

[Source]

fun box zone_name()
: String val

Returns


local_date

[Source]

fun box local_date()
: Date val

Returns


local_tod

[Source]

fun box local_tod()
: TimeOfDay val

Returns


offset_sec

[Source]

fun box offset_sec()
: I32 val

Returns


abbreviation

[Source]

fun box abbreviation()
: String val

Returns


is_dst

[Source]

fun box is_dst()
: Bool val

Returns


string

[Source]

RFC 3339 / ISO 8601 representation of this ZonedDateTime. Format: YYYY-MM-DDTHH:MM:SS[.nnnnnnnnn][Z|±HH:MM]

  • Date part comes from local_date().string() (YYYY-MM-DD, negative years prefixed with '-').
  • Time part comes from local_tod().string() (HH:MM:SS, or HH:MM:SS.nnnnnnnnn when sub-second precision is non-zero).
  • Offset is Z for zero offset, or ±HH:MM otherwise (sub-minute offsets — LMT-era — are rounded for the suffix; precise value remains available via offset_sec()).

The IANA zone name is NOT in the output — RFC 3339 carries an offset, not a zone. Use zone_name() separately if you need it.

fun box string()
: String iso^

Returns