#Moonbit/Core Time

    #Overview

    Package time provides functionality for measuring and manipulating time.

    The calendrical calculations always assume a ISO 8601 calendar, with no leap seconds.

    To create a datatime that represents the current time, you need to obtain the unix second and time zone offset from the wasi package (wasm-gc backend) or other FFI functions, and manually create a datetime.

    ///|
    test {
    // creates a UTC+8 fixed time zone.
    let zone = @time.fixed_zone("Asia/Shanghai", 8 * 60 * 60)

    // creates a ZonedDateTime from unix second and time zone.
    let date_time = @time.unix(1714227729L, nanosecond=1000, zone~)
    inspect(date_time, content="2024-04-27T22:22:09.000001+08:00[Asia/Shanghai]")
    }

    Use @time.Zone::from_tzif(id, data) to load a caller-supplied TZif v1–v4 file. data is a BytesView; complete Bytes values can also be passed. The id labels the zone; the constructor does not look up timezone database files. Zone::from_tzif2 is deprecated in favor of this interface.

    On the native backend, @time.local_zone() loads a snapshot of the system-configured local timezone on Linux, macOS, and Windows. Retain the returned Zone for repeated conversions; those conversions do no OS I/O. Calling local_zone() again reads the latest installed settings and rules. OS failures raise LocalZoneError, containing the native error code, operation context, and system message. Missing, malformed, or unsupported timezone data also raises an error. On JavaScript, local_zone() uses globalThis.Temporal when available, with Date and Intl.DateTimeFormat as a fallback. No polyfill or filesystem access is required. Both paths resolve offsets at the requested date and support the same local-time and field-edit policies described below. The returned zone captures the runtime's local timezone identifier, so changing the default zone does not change its identifier. Rules remain supplied by the runtime rather than copied into an independent snapshot. Loading raises if neither Temporal nor the required Intl support is available.

    JavaScript host zones have empty offset abbreviations. Their is_dst() returns false because these APIs do not expose the DST flag; this does not mean that the offset is standard time. Numeric offsets and clock-change handling remain available, including historical offsets measured in seconds. All JS host zones, including UTC and Etc/GMT zones, query the runtime for offsets at the requested instant. The deprecated is_fixed() conservatively returns false for host zones.

    The function raises on Wasm; caller-supplied TZif loading remains portable.

    Linux and macOS read /etc/localtime, independently of the process's TZ environment variable. Windows uses the system's local timezone and daylight-saving settings without requiring ICU. The loader detects the Windows 8 year-range API at runtime and uses a registry fallback on Windows 7.

    The returned ID is a source label. Unix uses the zoneinfo symlink's name when recoverable and otherwise local; Windows uses its registry key name, such as Eastern Standard Time, and otherwise local. Windows offset abbreviations are numeric. IDs and DST flags can differ between Windows and IANA data.

    Historical accuracy is limited by the data supplied by the OS or JS runtime. Native zones retain their data until you explicitly load a fresh snapshot.

    Zone equality (==, !=, and the Eq implementation) is deprecated. Existing comparisons retain their behavior, but compare representations rather than establishing equivalent timezone rules: a TZif zone and a runtime-provided zone can compare unequal even when their conversions agree. Compare Zone::to_string() only when you mean to compare source labels. To compare offsets at a particular instant, construct a ZonedDateTime in each zone and compare offset().seconds(). Neither comparison establishes that the zones agree at other instants.

    Zone::is_fixed() is also deprecated, with its existing results preserved. Host providers cannot always establish whether an offset is constant, so false can mean unknown. Resolve the offset at the required instant instead, for example with ZonedDateTime::from_unix_second(..., zone~).offset(). The fixed_zone(...) constructor remains available for intentionally constant-offset zones.

    TZif loading uses explicit transitions for recorded history and evaluates the footer's recurring rules from the last transition onward. When there are no transitions, the footer governs all timestamps. Evaluation is portable across backends and does not consult the host's timezone settings. A daylight footer without explicit transition rules raises an error instead of assuming defaults. A footer that disagrees with the final transition's offset, DST flag, or designation also raises an error. Adjacent or overlapping annual daylight periods are treated as continuous daylight time. Without a footer, the final recorded offset continues indefinitely. Leap-bearing transition times are converted to Unix seconds. For v4, transitions needing missing earlier leap history raise an error; after leap-table expiration, the last known correction is retained.

    PlainDateTime holds calendar and clock fields without a time zone: 01:00 means a clock reading, not one elapsed hour since midnight. A zone can map that reading to one instant, multiple instants when clocks move backward, or no instant when clocks skip forward.

    ZonedDateTime::from_plain, ZonedDateTime::of, and date_time accept an optional disambiguation argument when resolving those readings:

    PolicyRepeated reading (overlap)Skipped reading (gap)
    Compatible (default)Choose the earlier instantShift forward by the gap
    EarlierChoose the earlier instantShift backward by the gap
    LaterChoose the later instantShift forward by the gap
    RejectRaise an errorRaise an error

    For a jump from 02:00 to 03:00, a requested 02:30 becomes 03:30 under Compatible or Later, 01:30 under Earlier, and raises under Reject. Unambiguous readings are preserved under every policy. These rules apply to both recorded and recurring changes.

    Field edits (with_year, with_month, with_day, with_ordinal, with_hour, with_minute, with_second, and with_nanosecond) also accept disambiguation and a separate offset : OffsetPolicy option, following Temporal's rules:

    Offset policyTreatment of the original offset at the edited local time
    Prefer (default)Use it if valid; otherwise resolve using the zone and disambiguation
    IgnoreResolve using the zone and disambiguation, ignoring the original offset
    UseCompute the instant using the original offset, then project it into the zone; local fields can change
    RejectUse it if valid; otherwise raise, even if the edited local time is unambiguous

    An accepted offset already selects an instant, so disambiguation is not used. The default Prefer plus Compatible preserves existing behavior: editing the second occurrence of 01:30 to 01:45 retains the second occurrence. To choose the first explicitly, use offset=Ignore, disambiguation=Earlier. Similarly, Prefer plus Reject accepts an overlap if the original offset is still valid, whereas Ignore plus Reject raises for that overlap.

    ///|
    test {
    let plain = @time.PlainDateTime::of(2040, 1, 1, hour=1)
    let zone = @time.fixed_zone("Example", 3600)
    let value = @time.ZonedDateTime::from_plain(
    plain,
    zone~,
    disambiguation=Reject,
    )
    // A fixed zone has exactly one matching instant for every local reading.
    inspect(value, content="2040-01-01T01:00:00+01:00[Example]")
    let offset : @time.OffsetPolicy = Ignore
    debug_inspect(
    value.with_hour(2, offset~, disambiguation=Reject).to_string(),
    content="\"2040-01-01T02:00:00+01:00[Example]\"",
    )
    }

    add_hours, add_minutes, add_seconds, and add_nanoseconds add elapsed time on the Unix timeline, then obtain the zone's offset at the resulting instant. They need no disambiguation policy. In contrast, add_years, add_months, add_weeks, and add_days operate on local calendar fields, retaining a valid original offset and otherwise resolving with Compatible. Across a one-hour daylight-saving change, adding one calendar day can span 23 or 25 elapsed hours; adding 24 hours always advances the instant by 86400 seconds.

    ZonedDateTime::from_plain_datetime is deprecated but keeps its non-raising signature and Compatible behavior. Migrate to ZonedDateTime::from_plain, which raises when Reject is requested and the input is ambiguous or missing.

    Gap adjustments beyond the supported date range remain a known limitation: those inputs retain the historical, unresolved result and may not round trip through Unix time. The policy for that boundary is deferred.

    #TODOs

    • Convert from/to RFC format string.
    • Custom string formatter.
    • Support monotonic clock to accurately measure the elapsed time.
    • Support different calendar system, such as Chinese calendar system.

    LocalZoneError

    pub suberror LocalZoneError {
    LocalZoneError(UInt, context~ : String, message~ : String)
    }

    An OS failure while loading the system local timezone. The code is a Win32 error on Windows and errno on Unix. The message is supplied by the OS and can be empty when no description is available. Malformed timezone data is reported separately by the timezone decoder.

    LocalZoneError::output

    fn LocalZoneError::output(self : LocalZoneError, logger : &Logger) -> Unit

    LocalZoneError::to_string

    fn LocalZoneError::to_string(self : LocalZoneError) -> String

    Disambiguation

    pub(all) enum Disambiguation {
    Compatible
    Earlier
    Later
    Reject
    } derive(Eq,
    Debug
    )

    How to resolve a local clock reading when a zone's offset changes. Unambiguous readings are unchanged by every policy.

    Disambiguation::equal

    #deprecated("`Disambiguation::equal` is deprecated, use `Eq::equal` instead.")
    fn Disambiguation::equal(Disambiguation, Disambiguation) -> Bool

    Disambiguation::not_equal

    #deprecated("`Disambiguation::not_equal` is deprecated, use `Eq::not_equal` instead.")
    fn Disambiguation::not_equal(x : Disambiguation, y : Disambiguation) -> Bool

    Disambiguation::to_repr

    #deprecated("`Disambiguation::to_repr` is deprecated, use `@moonbitlang/core/debug.Debug::to_repr` instead.")
    fn Disambiguation::to_repr(Disambiguation) ->
    Repr

    Duration

    An amount of time with nanosecond precision.
    impl Show for Duration
    impl FromStr for Duration

    Duration::add_duration

    fn Duration::add_duration(self : Duration, other : Duration) -> Duration raise

    Adds other duration to this duration, and returns a new duration.

    Duration::add_hours

    fn Duration::add_hours(self : Duration, hours : Int64) -> Duration raise

    Adds specified hours to this duration, and returns a new duration.

    Duration::add_minutes

    fn Duration::add_minutes(self : Duration, minutes : Int64) -> Duration raise

    Adds specified minutes to this duration, and returns a new duration.

    Duration::add_nanoseconds

    fn Duration::add_nanoseconds(self : Duration, nanoseconds : Int64) -> Duration raise

    Adds specified nanoseconds to this duration, and returns a new duration.

    Duration::add_seconds

    fn Duration::add_seconds(self : Duration, seconds : Int64) -> Duration raise

    Adds specified seconds to this duration, and returns a new duration.

    Duration::compare

    #deprecated("`Duration::compare` is deprecated, use `Compare::compare` instead.")
    fn Duration::compare(Duration, Duration) -> Int

    Duration::equal

    #deprecated("`Duration::equal` is deprecated, use `Eq::equal` instead.")
    fn Duration::equal(Duration, Duration) -> Bool

    Duration::from_str

    #deprecated("`Duration::from_str` is deprecated, use `@moonbitlang/core/string.FromStr::from_str` instead.")
    fn Duration::from_str(str : StringView) -> Duration raise

    Duration::from_string

    #deprecated("Use `Duration::from_str` instead")
    fn Duration::from_string(str : String) -> Duration raise

    Parses a ISO 8601 format string like PT[n]H[n]M[n].[n]S.

    Duration::is_neg

    fn Duration::is_neg(self : Duration) -> Bool

    Checks if this duration is negative.

    Duration::is_zero

    fn Duration::is_zero(self : Duration) -> Bool

    Checks if this duration is zero length.

    Duration::nanoseconds

    fn Duration::nanoseconds(self : Duration) -> Int

    Returns the number of nanoseconds in this duration.

    Duration::not_equal

    #deprecated("`Duration::not_equal` is deprecated, use `Eq::not_equal` instead.")
    fn Duration::not_equal(x : Duration, y : Duration) -> Bool

    Duration::of

    fn Duration::of(hours? : Int64, minutes? : Int64, seconds? : Int64, nanoseconds? : Int64) -> Duration raise

    Creates a Duration from hours, minutes, seconds and nanoseconds.

    Duration::op_add

    fn Duration::op_add(self : Duration, other : Duration) -> Duration raise

    Duration::op_ge

    #deprecated("`Duration::op_ge` is deprecated, use `Compare::op_ge` instead.")
    fn Duration::op_ge(x : Duration, y : Duration) -> Bool

    Duration::op_gt

    #deprecated("`Duration::op_gt` is deprecated, use `Compare::op_gt` instead.")
    fn Duration::op_gt(x : Duration, y : Duration) -> Bool

    Duration::op_le

    #deprecated("`Duration::op_le` is deprecated, use `Compare::op_le` instead.")
    fn Duration::op_le(x : Duration, y : Duration) -> Bool

    Duration::op_lt

    #deprecated("`Duration::op_lt` is deprecated, use `Compare::op_lt` instead.")
    fn Duration::op_lt(x : Duration, y : Duration) -> Bool

    Duration::output

    #deprecated("`Duration::output` is deprecated, use `Show::output` instead.")
    fn Duration::output(self : Duration, logger : &Logger) -> Unit

    Duration::seconds

    fn Duration::seconds(self : Duration) -> Int64

    Returns the number of seconds in this duration.

    Duration::to_nanoseconds

    fn Duration::to_nanoseconds(self : Duration) -> Int64

    Converts this duration to the total length in nanoseconds.

    Duration::to_repr

    #deprecated("`Duration::to_repr` is deprecated, use `@moonbitlang/core/debug.Debug::to_repr` instead.")
    fn Duration::to_repr(Duration) ->
    Repr

    Duration::to_string

    fn Duration::to_string(self : Duration) -> String

    Returns a string representation of this duration using ISO 8601 representation.

    Duration::with_nanoseconds

    fn Duration::with_nanoseconds(self : Duration, nanoseconds : Int) -> Duration raise

    Returns a new duration with the specified nanosecond of second.

    Duration::with_seconds

    fn Duration::with_seconds(self : Duration, seconds : Int64) -> Duration

    Returns a new duration with the specified amount of seconds.

    Duration::zero

    fn Duration::zero() -> Duration

    Returns a zero length duration.

    OffsetPolicy

    pub(all) enum OffsetPolicy {
    Prefer
    Ignore
    Use
    Reject
    } derive(Eq,
    Debug
    )

    How field edits interpret the original UTC offset, following Temporal. An accepted offset determines the instant before Disambiguation is used. When resolving from the zone instead, Disambiguation handles gaps and overlaps.

    OffsetPolicy::equal

    #deprecated("`OffsetPolicy::equal` is deprecated, use `Eq::equal` instead.")
    fn OffsetPolicy::equal(OffsetPolicy, OffsetPolicy) -> Bool

    OffsetPolicy::not_equal

    #deprecated("`OffsetPolicy::not_equal` is deprecated, use `Eq::not_equal` instead.")
    fn OffsetPolicy::not_equal(x : OffsetPolicy, y : OffsetPolicy) -> Bool

    OffsetPolicy::to_repr

    #deprecated("`OffsetPolicy::to_repr` is deprecated, use `@moonbitlang/core/debug.Debug::to_repr` instead.")
    fn OffsetPolicy::to_repr(OffsetPolicy) ->
    Repr

    Period

    An amount of time representing by years, months and days in the ISO-8601 calendar system.
    impl Show for Period

    Period::add_days

    fn Period::add_days(self : Period, days : Int) -> Period raise

    Adds specified days to this period, and returns a new period.

    Period::add_months

    fn Period::add_months(self : Period, months : Int) -> Period raise

    Adds specified months to this period, and returns a new period.

    Period::add_period

    fn Period::add_period(self : Period, other : Period) -> Period raise

    Adds other period to this period, and returns a new period.

    Period::add_weeks

    fn Period::add_weeks(self : Period, weeks : Int) -> Period raise

    Adds specified weeks to this period, and returns a new period.

    Period::add_years

    fn Period::add_years(self : Period, years : Int) -> Period raise

    Adds specified years to this period, and returns a new period.

    Period::compare

    #deprecated("`Period::compare` is deprecated, use `Compare::compare` instead.")
    fn Period::compare(Period, Period) -> Int

    Period::days

    fn Period::days(self : Period) -> Int

    Returns the number of days in this duration.

    Period::equal

    #deprecated("`Period::equal` is deprecated, use `Eq::equal` instead.")
    fn Period::equal(Period, Period) -> Bool

    Period::from_string

    fn Period::from_string(str : String) -> Period raise

    Parses a ISO 8601 format string like P[n]Y[n]M[n]D.

    Period::is_neg

    fn Period::is_neg(self : Period) -> Bool

    Checks if this period is negative.

    Period::is_zero

    fn Period::is_zero(self : Period) -> Bool

    Checks if this period is zero length.

    Period::months

    fn Period::months(self : Period) -> Int

    Returns the number of months in this duration.

    Period::multiply

    fn Period::multiply(self : Period, n : Int) -> Period raise

    Returns a new period with all elements in this period multiplied by the specified value.

    Period::negated

    fn Period::negated(self : Period) -> Period raise

    Returns a new period with all elements in this period negated.

    Period::not_equal

    #deprecated("`Period::not_equal` is deprecated, use `Eq::not_equal` instead.")
    fn Period::not_equal(x : Period, y : Period) -> Bool

    Period::of

    fn Period::of(years? : Int, months? : Int, days? : Int) -> Period

    Creates a Period from years, months, and days.

    Period::op_add

    fn Period::op_add(self : Period, other : Period) -> Period raise

    Period::op_ge

    #deprecated("`Period::op_ge` is deprecated, use `Compare::op_ge` instead.")
    fn Period::op_ge(x : Period, y : Period) -> Bool

    Period::op_gt

    #deprecated("`Period::op_gt` is deprecated, use `Compare::op_gt` instead.")
    fn Period::op_gt(x : Period, y : Period) -> Bool

    Period::op_le

    #deprecated("`Period::op_le` is deprecated, use `Compare::op_le` instead.")
    fn Period::op_le(x : Period, y : Period) -> Bool

    Period::op_lt

    #deprecated("`Period::op_lt` is deprecated, use `Compare::op_lt` instead.")
    fn Period::op_lt(x : Period, y : Period) -> Bool

    Period::op_sub

    fn Period::op_sub(self : Period, other : Period) -> Period raise

    Period::output

    #deprecated("`Period::output` is deprecated, use `Show::output` instead.")
    fn Period::output(self : Period, logger : &Logger) -> Unit

    Period::to_repr

    #deprecated("`Period::to_repr` is deprecated, use `@moonbitlang/core/debug.Debug::to_repr` instead.")
    fn Period::to_repr(Period) ->
    Repr

    Period::to_string

    fn Period::to_string(self : Period) -> String

    Returns a string representation of this period using ISO 8601 representation.

    Period::to_total_months

    fn Period::to_total_months(self : Period) -> Int64

    Returns the total number of months in this period.

    Period::with_days

    fn Period::with_days(self : Period, days : Int) -> Period

    Returns a new period with the specified amount of days.

    Period::with_months

    fn Period::with_months(self : Period, months : Int) -> Period

    Returns a new period with the specified amount of months.

    Period::with_years

    fn Period::with_years(self : Period, years : Int) -> Period

    Returns a new period with the specified amount of years.

    Period::years

    fn Period::years(self : Period) -> Int

    Returns the number of years in this duration.

    Period::zero

    fn Period::zero() -> Period

    Returns a zero length period.

    PlainDate

    type PlainDate derive(
    Debug
    )

    A date without a time zone in the ISO 8601 calendar system.
    impl Eq for PlainDate
    impl Show for PlainDate
    impl ToJson for PlainDate

    PlainDate::add_days

    fn PlainDate::add_days(self : PlainDate, days : Int64) -> PlainDate raise

    Adds specified days to this date, and returns a new date.

    PlainDate::add_months

    fn PlainDate::add_months(self : PlainDate, months : Int64) -> PlainDate raise

    Adds specified months to this date, and returns a new date.

    PlainDate::add_period

    fn PlainDate::add_period(self : PlainDate, period : Period) -> PlainDate raise

    Adds a period to this date, and returns a new date.

    PlainDate::add_weeks

    fn PlainDate::add_weeks(self : PlainDate, weeks : Int64) -> PlainDate raise

    Adds specified weeks to this date, and returns a new date.

    PlainDate::add_years

    fn PlainDate::add_years(self : PlainDate, years : Int64) -> PlainDate raise

    Adds specified years to this date, and returns a new date.

    PlainDate::compare

    #deprecated("`PlainDate::compare` is deprecated, use `Compare::compare` instead.")
    fn PlainDate::compare(self : PlainDate, other : PlainDate) -> Int

    PlainDate::day

    fn PlainDate::day(self : PlainDate) -> Int

    Returns the day of the month.

    PlainDate::days_in_month

    fn PlainDate::days_in_month(self : PlainDate) -> Int

    Returns the number of days in the month.

    PlainDate::days_in_week

    fn PlainDate::days_in_week(_self : PlainDate) -> Int

    Returns the number of days in the week.

    PlainDate::days_in_year

    fn PlainDate::days_in_year(self : PlainDate) -> Int

    Returns the number of days in the year.

    PlainDate::equal

    #deprecated("`PlainDate::equal` is deprecated, use `Eq::equal` instead.")
    fn PlainDate::equal(self : PlainDate, other : PlainDate) -> Bool

    PlainDate::era

    fn PlainDate::era(self : PlainDate) -> String

    Returns the era of this date.

    PlainDate::era_year

    fn PlainDate::era_year(self : PlainDate) -> Int

    Returns the year of the era of this date.

    PlainDate::from_json

    #deprecated("`PlainDate::from_json` is deprecated, use `@moonbitlang/core/json.FromJson::from_json` instead.")
    fn PlainDate::from_json(json : Json, path :
    JsonPath
    ) -> PlainDate raise
    JsonDecodeError

    PlainDate::from_str

    #deprecated("`PlainDate::from_str` is deprecated, use `@moonbitlang/core/string.FromStr::from_str` instead.")
    fn PlainDate::from_str(str : StringView) -> PlainDate raise

    PlainDate::from_string

    #deprecated("Use `PlainDate::from_str` instead")
    fn PlainDate::from_string(str : String) -> PlainDate raise

    Creates a PlainDate from a string, like "2008-08-08".

    PlainDate::from_unix_day

    fn PlainDate::from_unix_day(unix_day : Int64) -> PlainDate raise

    Creates a date from the days count since unix epoch.

    PlainDate::from_year_ord

    fn PlainDate::from_year_ord(year : Int, ordinal : Int) -> PlainDate raise

    Creates a PlainDate from year and ordinal day.

    PlainDate::in_leap_year

    fn PlainDate::in_leap_year(self : PlainDate) -> Bool

    Checks if the date is in a leap year.

    PlainDate::month

    fn PlainDate::month(self : PlainDate) -> Int

    Returns the ordinal number of month in the current year.

    PlainDate::months_in_year

    fn PlainDate::months_in_year(_self : PlainDate) -> Int

    Returns the number of months in the year.

    PlainDate::not_equal

    #deprecated("`PlainDate::not_equal` is deprecated, use `Eq::not_equal` instead.")
    fn PlainDate::not_equal(x : PlainDate, y : PlainDate) -> Bool

    PlainDate::of

    fn PlainDate::of(year : Int, month : Int, day : Int) -> PlainDate raise

    Creates a PlainDate from the year, month and day.

    PlainDate::op_ge

    #deprecated("`PlainDate::op_ge` is deprecated, use `Compare::op_ge` instead.")
    fn PlainDate::op_ge(x : PlainDate, y : PlainDate) -> Bool

    PlainDate::op_gt

    #deprecated("`PlainDate::op_gt` is deprecated, use `Compare::op_gt` instead.")
    fn PlainDate::op_gt(x : PlainDate, y : PlainDate) -> Bool

    PlainDate::op_le

    #deprecated("`PlainDate::op_le` is deprecated, use `Compare::op_le` instead.")
    fn PlainDate::op_le(x : PlainDate, y : PlainDate) -> Bool

    PlainDate::op_lt

    #deprecated("`PlainDate::op_lt` is deprecated, use `Compare::op_lt` instead.")
    fn PlainDate::op_lt(x : PlainDate, y : PlainDate) -> Bool

    PlainDate::ordinal

    fn PlainDate::ordinal(self : PlainDate) -> Int

    Returns the ordinal day of the year.

    PlainDate::output

    #deprecated("`PlainDate::output` is deprecated, use `Show::output` instead.")
    fn PlainDate::output(self : PlainDate, logger : &Logger) -> Unit

    PlainDate::to_json

    #deprecated("`PlainDate::to_json` is deprecated, use `ToJson::to_json` instead.")
    fn PlainDate::to_json(self : PlainDate) -> Json

    PlainDate::to_repr

    #deprecated("`PlainDate::to_repr` is deprecated, use `@moonbitlang/core/debug.Debug::to_repr` instead.")
    fn PlainDate::to_repr(PlainDate) ->
    Repr

    PlainDate::to_string

    fn PlainDate::to_string(self : PlainDate) -> String

    Returns a string representing the date.

    PlainDate::to_unix_day

    fn PlainDate::to_unix_day(self : PlainDate) -> Int64

    Returns the days count since unix epoch of this date.

    PlainDate::until

    fn PlainDate::until(self : PlainDate, end : PlainDate) -> Period raise

    Returns the period between this date and another date.

    PlainDate::weekday

    fn PlainDate::weekday(self : PlainDate) -> Weekday

    Returns the weekday.

    PlainDate::with_day

    fn PlainDate::with_day(self : PlainDate, day : Int) -> PlainDate raise

    Returns a new date with the specified day of month.

    PlainDate::with_month

    fn PlainDate::with_month(self : PlainDate, month : Int) -> PlainDate raise

    Returns a new date with the specified month.

    PlainDate::with_ordinal

    fn PlainDate::with_ordinal(self : PlainDate, ordinal : Int) -> PlainDate raise

    Returns a new date with the specified ordinal day of year.

    PlainDate::with_year

    fn PlainDate::with_year(self : PlainDate, year : Int) -> PlainDate raise

    Returns a new date with the specified year.

    PlainDate::year

    fn PlainDate::year(self : PlainDate) -> Int

    Returns the number of years relative to a calendar-specific epoch.

    PlainDateTime

    A datetime without a time zone in the ISO 8601 calendar system.

    PlainDateTime::add_days

    fn PlainDateTime::add_days(self : PlainDateTime, days : Int64) -> PlainDateTime raise

    Adds specified days to this datetime, and returns a new datetime.

    PlainDateTime::add_duration

    fn PlainDateTime::add_duration(self : PlainDateTime, duration : Duration) -> PlainDateTime raise

    Adds a duration of time to this datetime, and returns a new datetime.

    PlainDateTime::add_hours

    fn PlainDateTime::add_hours(self : PlainDateTime, hours : Int64) -> PlainDateTime raise

    Adds specified hours to this datetime, and returns a new datetime.

    PlainDateTime::add_minutes

    fn PlainDateTime::add_minutes(self : PlainDateTime, minutes : Int64) -> PlainDateTime raise

    Adds specified minutes to this datetime, and returns a new datetime.

    PlainDateTime::add_months

    fn PlainDateTime::add_months(self : PlainDateTime, months : Int64) -> PlainDateTime raise

    Adds specified months to this datetime, and returns a new datetime.

    PlainDateTime::add_nanoseconds

    fn PlainDateTime::add_nanoseconds(self : PlainDateTime, nanoseconds : Int64) -> PlainDateTime raise

    Adds specified nanoseconds to this datetime, and returns a new datetime.

    PlainDateTime::add_period

    fn PlainDateTime::add_period(self : PlainDateTime, period : Period) -> PlainDateTime raise

    Adds a period of date to this datetime, and returns a new datetime.

    PlainDateTime::add_seconds

    fn PlainDateTime::add_seconds(self : PlainDateTime, seconds : Int64) -> PlainDateTime raise

    Adds specified seconds to this datetime, and returns a new datetime.

    PlainDateTime::add_weeks

    fn PlainDateTime::add_weeks(self : PlainDateTime, weeks : Int64) -> PlainDateTime raise

    Adds specified weeks to this datetime, and returns a new datetime.

    PlainDateTime::add_years

    fn PlainDateTime::add_years(self : PlainDateTime, years : Int64) -> PlainDateTime raise

    Adds specified years to this datetime, and returns a new datetime.

    PlainDateTime::compare

    #deprecated("`PlainDateTime::compare` is deprecated, use `Compare::compare` instead.")
    fn PlainDateTime::compare(PlainDateTime, PlainDateTime) -> Int

    PlainDateTime::day

    fn PlainDateTime::day(self : PlainDateTime) -> Int

    Returns the day of month of this datetime.

    PlainDateTime::days_in_month

    fn PlainDateTime::days_in_month(self : PlainDateTime) -> Int

    Returns the number of days in a month of this datetime.

    PlainDateTime::days_in_week

    fn PlainDateTime::days_in_week(self : PlainDateTime) -> Int

    Returns the number of days in a week of this datetime.

    PlainDateTime::days_in_year

    fn PlainDateTime::days_in_year(self : PlainDateTime) -> Int

    Returns the number of days in a year of this datetime.

    PlainDateTime::equal

    #deprecated("`PlainDateTime::equal` is deprecated, use `Eq::equal` instead.")
    fn PlainDateTime::equal(PlainDateTime, PlainDateTime) -> Bool

    PlainDateTime::era

    fn PlainDateTime::era(self : PlainDateTime) -> String

    Returns the era of this datetime.

    PlainDateTime::era_year

    fn PlainDateTime::era_year(self : PlainDateTime) -> Int

    Returns the year of era of this datetime.

    PlainDateTime::from_json

    #deprecated("`PlainDateTime::from_json` is deprecated, use `@moonbitlang/core/json.FromJson::from_json` instead.")
    fn PlainDateTime::from_json(Json,
    JsonPath
    ) -> PlainDateTime raise
    JsonDecodeError

    PlainDateTime::from_str

    #deprecated("`PlainDateTime::from_str` is deprecated, use `@moonbitlang/core/string.FromStr::from_str` instead.")
    fn PlainDateTime::from_str(str : StringView) -> PlainDateTime raise

    PlainDateTime::from_string

    #deprecated("Use `PlainDateTime::from_str` instead")
    fn PlainDateTime::from_string(str : String) -> PlainDateTime raise

    Creates a PlainTime from a string, like '2008-08-08T20:00:00'.

    PlainDateTime::from_unix_second

    fn PlainDateTime::from_unix_second(second : Int64, nanosecond : Int, offset : ZoneOffset) -> PlainDateTime raise

    Creates a PlainDateTime from the elapsed seconds since the unix epoch.

    PlainDateTime::hour

    fn PlainDateTime::hour(self : PlainDateTime) -> Int

    Returns the hour of this datetime.

    PlainDateTime::in_leap_year

    fn PlainDateTime::in_leap_year(self : PlainDateTime) -> Bool

    Checks if this datetime is in a leap year.

    PlainDateTime::minute

    fn PlainDateTime::minute(self : PlainDateTime) -> Int

    Returns the minute of this datetime.

    PlainDateTime::month

    fn PlainDateTime::month(self : PlainDateTime) -> Int

    Returns the month of this datetime.

    PlainDateTime::months_in_year

    fn PlainDateTime::months_in_year(self : PlainDateTime) -> Int

    Returns the number of months in a year of this datetime.

    PlainDateTime::nanosecond

    fn PlainDateTime::nanosecond(self : PlainDateTime) -> Int

    Returns the nanosecond of this datetime.

    PlainDateTime::not_equal

    #deprecated("`PlainDateTime::not_equal` is deprecated, use `Eq::not_equal` instead.")
    fn PlainDateTime::not_equal(x : PlainDateTime, y : PlainDateTime) -> Bool

    PlainDateTime::of

    fn PlainDateTime::of(year : Int, month : Int, day : Int, hour? : Int, minute? : Int, second? : Int, nanosecond? : Int) -> PlainDateTime raise

    Creates a PlainDateTime from the year, month, day, hour, minute, second and nanosecond.

    PlainDateTime::op_ge

    #deprecated("`PlainDateTime::op_ge` is deprecated, use `Compare::op_ge` instead.")
    fn PlainDateTime::op_ge(x : PlainDateTime, y : PlainDateTime) -> Bool

    PlainDateTime::op_gt

    #deprecated("`PlainDateTime::op_gt` is deprecated, use `Compare::op_gt` instead.")
    fn PlainDateTime::op_gt(x : PlainDateTime, y : PlainDateTime) -> Bool

    PlainDateTime::op_le

    #deprecated("`PlainDateTime::op_le` is deprecated, use `Compare::op_le` instead.")
    fn PlainDateTime::op_le(x : PlainDateTime, y : PlainDateTime) -> Bool

    PlainDateTime::op_lt

    #deprecated("`PlainDateTime::op_lt` is deprecated, use `Compare::op_lt` instead.")
    fn PlainDateTime::op_lt(x : PlainDateTime, y : PlainDateTime) -> Bool

    PlainDateTime::ordinal

    fn PlainDateTime::ordinal(self : PlainDateTime) -> Int

    Returns the ordinal day of year of this datetime.

    PlainDateTime::output

    #deprecated("`PlainDateTime::output` is deprecated, use `Show::output` instead.")
    fn PlainDateTime::output(self : PlainDateTime, logger : &Logger) -> Unit

    PlainDateTime::second

    fn PlainDateTime::second(self : PlainDateTime) -> Int

    Returns the second of this datetime.

    PlainDateTime::to_json

    #deprecated("`PlainDateTime::to_json` is deprecated, use `ToJson::to_json` instead.")
    fn PlainDateTime::to_json(PlainDateTime) -> Json

    PlainDateTime::to_plain_date

    fn PlainDateTime::to_plain_date(self : PlainDateTime) -> PlainDate

    Returns the date part of this datetime.

    PlainDateTime::to_plain_time

    fn PlainDateTime::to_plain_time(self : PlainDateTime) -> PlainTime

    Returns the time part of this datetime.

    PlainDateTime::to_repr

    #deprecated("`PlainDateTime::to_repr` is deprecated, use `@moonbitlang/core/debug.Debug::to_repr` instead.")
    fn PlainDateTime::to_repr(PlainDateTime) ->
    Repr

    PlainDateTime::to_string

    fn PlainDateTime::to_string(self : PlainDateTime) -> String

    Returns a string representing the datetime.

    PlainDateTime::to_unix_second

    fn PlainDateTime::to_unix_second(self : PlainDateTime) -> Int64

    Converts this datetime to the elapsed seconds since the unix epoch.

    PlainDateTime::weekday

    fn PlainDateTime::weekday(self : PlainDateTime) -> Weekday

    Returns the weekday of this datetime.

    PlainDateTime::with_day

    fn PlainDateTime::with_day(self : PlainDateTime, day : Int) -> PlainDateTime raise

    Returns a new datetime with the specified day of month.

    PlainDateTime::with_hour

    fn PlainDateTime::with_hour(self : PlainDateTime, hour : Int) -> PlainDateTime raise

    Returns a new datetime with the specified hour.

    PlainDateTime::with_minute

    fn PlainDateTime::with_minute(self : PlainDateTime, minute : Int) -> PlainDateTime raise

    Returns a new datetime with the specified minute.

    PlainDateTime::with_month

    fn PlainDateTime::with_month(self : PlainDateTime, month : Int) -> PlainDateTime raise

    Returns a new datetime with the specified month.

    PlainDateTime::with_nanosecond

    fn PlainDateTime::with_nanosecond(self : PlainDateTime, nanosecond : Int) -> PlainDateTime raise

    Returns a new datetime with the specified nanosecond.

    PlainDateTime::with_ordinal

    fn PlainDateTime::with_ordinal(self : PlainDateTime, ordinal : Int) -> PlainDateTime raise

    Returns a new datetime with the specified ordinal day of year.

    PlainDateTime::with_second

    fn PlainDateTime::with_second(self : PlainDateTime, second : Int) -> PlainDateTime raise

    Returns a new datetime with the specified second.

    PlainDateTime::with_year

    fn PlainDateTime::with_year(self : PlainDateTime, year : Int) -> PlainDateTime raise

    Returns a new datetime with the specified year.

    PlainDateTime::year

    fn PlainDateTime::year(self : PlainDateTime) -> Int

    Returns the year of this datetime.

    PlainTime

    A time without a time zone
    impl Show for PlainTime
    impl ToJson for PlainTime

    PlainTime::add_duration

    fn PlainTime::add_duration(self : PlainTime, duration : Duration) -> PlainTime raise

    Adds a duration to this time, and returns a new time.

    PlainTime::add_hours

    fn PlainTime::add_hours(self : PlainTime, hours : Int64) -> PlainTime raise

    Adds specified hours to this time, and returns a new time.

    PlainTime::add_minutes

    fn PlainTime::add_minutes(self : PlainTime, minutes : Int64) -> PlainTime raise

    Adds specified minutes to this time, and returns a new time.

    PlainTime::add_nanoseconds

    fn PlainTime::add_nanoseconds(self : PlainTime, nanoseconds : Int64) -> PlainTime raise

    Adds specified nanoseconds to this time, and returns a new time.

    PlainTime::add_seconds

    fn PlainTime::add_seconds(self : PlainTime, seconds : Int64) -> PlainTime raise

    Adds specified seconds to this time, and returns a new time.

    PlainTime::at_date

    fn PlainTime::at_date(self : PlainTime, date : PlainDate) -> PlainDateTime

    Combines this time with a date to creates a PlainDateTime

    PlainTime::compare

    #deprecated("`PlainTime::compare` is deprecated, use `Compare::compare` instead.")
    fn PlainTime::compare(PlainTime, PlainTime) -> Int

    PlainTime::equal

    #deprecated("`PlainTime::equal` is deprecated, use `Eq::equal` instead.")
    fn PlainTime::equal(PlainTime, PlainTime) -> Bool

    PlainTime::from_json

    #deprecated("`PlainTime::from_json` is deprecated, use `@moonbitlang/core/json.FromJson::from_json` instead.")
    fn PlainTime::from_json(json : Json, path :
    JsonPath
    ) -> PlainTime raise
    JsonDecodeError

    PlainTime::from_nanosecond_of_day

    fn PlainTime::from_nanosecond_of_day(nanosecond : Int64) -> PlainTime raise

    Creates a PlainTime from the total nanoseconds of the day.

    PlainTime::from_second_of_day

    fn PlainTime::from_second_of_day(second : Int) -> PlainTime raise

    Creates a PlainTime from the total seconds of the day.

    PlainTime::from_str

    #deprecated("`PlainTime::from_str` is deprecated, use `@moonbitlang/core/string.FromStr::from_str` instead.")
    fn PlainTime::from_str(str : StringView) -> PlainTime raise

    PlainTime::from_string

    #deprecated("Use `PlainTime::from_str` instead")
    fn PlainTime::from_string(str : String) -> PlainTime raise

    Creates a PlainTime from a string, like '10:20:30.45678'.

    PlainTime::hour

    fn PlainTime::hour(self : PlainTime) -> Int

    Returns the hour of this time.

    PlainTime::minute

    fn PlainTime::minute(self : PlainTime) -> Int

    Returns the minute of this time.

    PlainTime::nanosecond

    fn PlainTime::nanosecond(self : PlainTime) -> Int

    Returns the nanosecond of this time.

    PlainTime::nanosecond_of_day

    fn PlainTime::nanosecond_of_day(self : PlainTime) -> Int64

    Returns the total nanoseconds of this time.

    PlainTime::not_equal

    #deprecated("`PlainTime::not_equal` is deprecated, use `Eq::not_equal` instead.")
    fn PlainTime::not_equal(x : PlainTime, y : PlainTime) -> Bool

    PlainTime::of

    fn PlainTime::of(hour : Int, minute : Int, second : Int, nanosecond : Int) -> PlainTime raise

    Creates a PlainTime from the hour, minute, second and nanosecond.

    PlainTime::op_ge

    #deprecated("`PlainTime::op_ge` is deprecated, use `Compare::op_ge` instead.")
    fn PlainTime::op_ge(x : PlainTime, y : PlainTime) -> Bool

    PlainTime::op_gt

    #deprecated("`PlainTime::op_gt` is deprecated, use `Compare::op_gt` instead.")
    fn PlainTime::op_gt(x : PlainTime, y : PlainTime) -> Bool

    PlainTime::op_le

    #deprecated("`PlainTime::op_le` is deprecated, use `Compare::op_le` instead.")
    fn PlainTime::op_le(x : PlainTime, y : PlainTime) -> Bool

    PlainTime::op_lt

    #deprecated("`PlainTime::op_lt` is deprecated, use `Compare::op_lt` instead.")
    fn PlainTime::op_lt(x : PlainTime, y : PlainTime) -> Bool

    PlainTime::output

    #deprecated("`PlainTime::output` is deprecated, use `Show::output` instead.")
    fn PlainTime::output(self : PlainTime, logger : &Logger) -> Unit

    PlainTime::second

    fn PlainTime::second(self : PlainTime) -> Int

    Returns the second of this time.

    PlainTime::second_of_day

    fn PlainTime::second_of_day(self : PlainTime) -> Int

    Returns the total seconds of this time.

    PlainTime::to_json

    #deprecated("`PlainTime::to_json` is deprecated, use `ToJson::to_json` instead.")
    fn PlainTime::to_json(self : PlainTime) -> Json

    PlainTime::to_repr

    #deprecated("`PlainTime::to_repr` is deprecated, use `@moonbitlang/core/debug.Debug::to_repr` instead.")
    fn PlainTime::to_repr(PlainTime) ->
    Repr

    PlainTime::to_string

    fn PlainTime::to_string(self : PlainTime) -> String

    Returns a string representing the time.

    PlainTime::until

    fn PlainTime::until(self : PlainTime, end : PlainTime) -> Duration raise

    Returns the duration between this time and another time.

    PlainTime::with_hour

    fn PlainTime::with_hour(self : PlainTime, hour : Int) -> PlainTime raise

    Returns a new time with the specified hour.

    PlainTime::with_minute

    fn PlainTime::with_minute(self : PlainTime, minute : Int) -> PlainTime raise

    Returns a new time with the specified minute.

    PlainTime::with_nanosecond

    fn PlainTime::with_nanosecond(self : PlainTime, nanosecond : Int) -> PlainTime raise

    Returns a new time with the specified nanosecond.

    PlainTime::with_second

    fn PlainTime::with_second(self : PlainTime, second : Int) -> PlainTime raise

    Returns a new time with the specified second.

    Weekday

    pub(all) enum Weekday {
    Monday
    Tuesday
    Wednesday
    Thursday
    Friday
    Saturday
    Sunday
    } derive(Eq,
    Debug
    )

    impl Show for Weekday

    Weekday::equal

    #deprecated("`Weekday::equal` is deprecated, use `Eq::equal` instead.")
    fn Weekday::equal(Weekday, Weekday) -> Bool

    Weekday::not_equal

    #deprecated("`Weekday::not_equal` is deprecated, use `Eq::not_equal` instead.")
    fn Weekday::not_equal(x : Weekday, y : Weekday) -> Bool

    Weekday::output

    #deprecated("`Weekday::output` is deprecated, use `Show::output` instead.")
    fn Weekday::output(self : Weekday, logger : &Logger) -> Unit

    Weekday::to_repr

    #deprecated("`Weekday::to_repr` is deprecated, use `@moonbitlang/core/debug.Debug::to_repr` instead.")
    fn Weekday::to_repr(Weekday) ->
    Repr

    Weekday::to_string

    #deprecated("`Weekday::to_string` is deprecated, use `Show::to_string` instead.")
    fn Weekday::to_string(self : Weekday) -> String

    Zone

    Time zone. Equality is deprecated: comparing representations does not establish equivalent timezone rules across different data sources.
    impl Eq for Zone
    impl Show for Zone

    Zone::equal

    #deprecated("Zone equality cannot establish equivalent timezone rules. Compare labels or offsets at a specific instant instead, according to your intent.")
    #deprecated("Zone equality cannot establish equivalent timezone rules. Compare labels or offsets at a specific instant instead, according to your intent.")
    fn Zone::equal(self : Zone, other : Zone) -> Bool

    Zone::from_tzif

    fn Zone::from_tzif(id : String, data : BytesView) -> Zone raise

    Creates a time zone from a complete TZif v1–v4 file.

    Versions 2–4 use the authoritative 64-bit transitions. Leap-bearing timestamps are converted to Unix seconds; a transition during an inserted leap second takes effect at the next ordinary second.

    A transition preceding a truncated leap history raises an error because its correction is unknown. After leap-table expiration, the last known correction continues to apply, assuming no further leap corrections.

    The footer governs timestamps on or after the last explicit transition, or all timestamps when there are no transitions. Seasonal footer rules are evaluated without consulting the host's timezone settings. A daylight designation without transition rules raises an error, since its behavior would require implementation-defined defaults. A footer disagreeing with the final transition's offset, DST flag, or designation also raises an error. Before the first transition, type 0 is used. Without a footer, the last explicit offset continues indefinitely (or type 0 when there are none). Offsets must fit ZoneOffset's range of -18 to +18 hours. Designations containing characters other than ASCII letters, digits, +, and - are replaced with the signed numeric offset, following RFC 9636.

    Zone::from_tzif2

    #deprecated("Use `Zone::from_tzif` with a `BytesView` instead")
    fn Zone::from_tzif2(id : String, data : FixedArray[Byte]) -> Zone raise

    Compatibility entry point for callers with a FixedArray[Byte]. Accepts the same TZif versions as Zone::from_tzif.

    Zone::is_fixed

    #deprecated("Host-backed zones cannot always determine whether their offset is fixed. Resolve the offset at the required instant instead.")
    fn Zone::is_fixed(self : Zone) -> Bool

    Checks if this zone is known to have a single offset without seasonal rules.

    Zone::not_equal

    #deprecated("Zone equality cannot establish equivalent timezone rules. Compare labels or offsets at a specific instant instead, according to your intent.")
    #deprecated("Zone equality cannot establish equivalent timezone rules. Compare labels or offsets at a specific instant instead, according to your intent.")
    fn Zone::not_equal(x : Zone, y : Zone) -> Bool

    Zone::output

    #deprecated("`Zone::output` is deprecated, use `Show::output` instead.")
    fn Zone::output(self : Zone, logger : &Logger) -> Unit

    Zone::to_repr

    #deprecated("`Zone::to_repr` is deprecated, use `@moonbitlang/core/debug.Debug::to_repr` instead.")
    fn Zone::to_repr(Zone) ->
    Repr

    Zone::to_string

    fn Zone::to_string(self : Zone) -> String

    Returns the fixed zone id (e.g. "UTC", "America/Los_Angeles", etc.)

    ZoneOffset

    type ZoneOffset derive(
    Debug
    )

    Time offset from UTC.
    impl Eq for ZoneOffset
    impl Show for ZoneOffset

    ZoneOffset::abbreviation

    fn ZoneOffset::abbreviation(self : ZoneOffset) -> String

    Returns the zone offset abbreviation, e.g. "PST", "CST", "EST", "UTC", etc.

    ZoneOffset::compare

    #deprecated("`ZoneOffset::compare` is deprecated, use `Compare::compare` instead.")
    fn ZoneOffset::compare(self : ZoneOffset, other : ZoneOffset) -> Int

    ZoneOffset::equal

    #deprecated("`ZoneOffset::equal` is deprecated, use `Eq::equal` instead.")
    fn ZoneOffset::equal(self : ZoneOffset, other : ZoneOffset) -> Bool

    ZoneOffset::from_seconds

    fn ZoneOffset::from_seconds(seconds : Int, abbrev? : String, dst? : Bool) -> ZoneOffset raise

    Creates a offset from seconds.

    ZoneOffset::id

    fn ZoneOffset::id(self : ZoneOffset) -> String

    Returns the offset id.

    ZoneOffset::is_dst

    fn ZoneOffset::is_dst(self : ZoneOffset) -> Bool

    Reports the daylight-saving flag supplied by the timezone data source. JavaScript host zones do not expose this metadata and return false; for those zones, false does not establish that standard time is in effect.

    ZoneOffset::not_equal

    #deprecated("`ZoneOffset::not_equal` is deprecated, use `Eq::not_equal` instead.")
    fn ZoneOffset::not_equal(x : ZoneOffset, y : ZoneOffset) -> Bool

    ZoneOffset::of

    fn ZoneOffset::of(hours? : Int, minutes? : Int, seconds? : Int, abbrev? : String, dst? : Bool) -> ZoneOffset raise

    Creates a offset from hours, minutes and seconds.

    ZoneOffset::op_ge

    #deprecated("`ZoneOffset::op_ge` is deprecated, use `Compare::op_ge` instead.")
    fn ZoneOffset::op_ge(x : ZoneOffset, y : ZoneOffset) -> Bool

    ZoneOffset::op_gt

    #deprecated("`ZoneOffset::op_gt` is deprecated, use `Compare::op_gt` instead.")
    fn ZoneOffset::op_gt(x : ZoneOffset, y : ZoneOffset) -> Bool

    ZoneOffset::op_le

    #deprecated("`ZoneOffset::op_le` is deprecated, use `Compare::op_le` instead.")
    fn ZoneOffset::op_le(x : ZoneOffset, y : ZoneOffset) -> Bool

    ZoneOffset::op_lt

    #deprecated("`ZoneOffset::op_lt` is deprecated, use `Compare::op_lt` instead.")
    fn ZoneOffset::op_lt(x : ZoneOffset, y : ZoneOffset) -> Bool

    ZoneOffset::output

    #deprecated("`ZoneOffset::output` is deprecated, use `Show::output` instead.")
    fn ZoneOffset::output(self : ZoneOffset, logger : &Logger) -> Unit

    ZoneOffset::seconds

    fn ZoneOffset::seconds(self : ZoneOffset) -> Int

    Returns the total seconds of this offset.

    ZoneOffset::to_repr

    #deprecated("`ZoneOffset::to_repr` is deprecated, use `@moonbitlang/core/debug.Debug::to_repr` instead.")
    fn ZoneOffset::to_repr(ZoneOffset) ->
    Repr

    ZoneOffset::to_string

    fn ZoneOffset::to_string(self : ZoneOffset) -> String

    Returns the offset id, e.g. "Z", "+08:00", "-05:30", etc.

    ZonedDateTime

    type ZonedDateTime derive(
    Debug
    )

    A datetime with a time zone and offset in the ISO 8601 calendar system. By default, local construction chooses the earlier instant in an overlap and moves forward across a gap. Edits retain a still-valid offset.

    ZonedDateTime::add_days

    fn ZonedDateTime::add_days(self : ZonedDateTime, days : Int64) -> ZonedDateTime raise

    Adds specified days to this datetime, and returns a new datetime.

    ZonedDateTime::add_hours

    fn ZonedDateTime::add_hours(self : ZonedDateTime, hours : Int64) -> ZonedDateTime raise

    Adds elapsed hours on the instant timeline, preserving the time zone. Across offset changes, 24 elapsed hours can differ from one calendar day.

    ZonedDateTime::add_minutes

    fn ZonedDateTime::add_minutes(self : ZonedDateTime, minutes : Int64) -> ZonedDateTime raise

    Adds elapsed minutes on the instant timeline, preserving the time zone.

    ZonedDateTime::add_months

    fn ZonedDateTime::add_months(self : ZonedDateTime, months : Int64) -> ZonedDateTime raise

    Adds specified months to this datetime, and returns a new datetime.

    ZonedDateTime::add_nanoseconds

    fn ZonedDateTime::add_nanoseconds(self : ZonedDateTime, nanoseconds : Int64) -> ZonedDateTime raise

    Adds elapsed nanoseconds on the instant timeline, preserving the time zone.

    ZonedDateTime::add_seconds

    fn ZonedDateTime::add_seconds(self : ZonedDateTime, seconds : Int64) -> ZonedDateTime raise

    Adds elapsed seconds on the instant timeline, preserving the time zone.

    ZonedDateTime::add_weeks

    fn ZonedDateTime::add_weeks(self : ZonedDateTime, weeks : Int64) -> ZonedDateTime raise

    Adds specified weeks to this datetime, and returns a new datetime.

    ZonedDateTime::add_years

    fn ZonedDateTime::add_years(self : ZonedDateTime, years : Int64) -> ZonedDateTime raise

    Adds specified years to this datetime, and returns a new datetime.

    ZonedDateTime::day

    fn ZonedDateTime::day(self : ZonedDateTime) -> Int

    Returns the day of month of this datetime.

    ZonedDateTime::days_in_month

    fn ZonedDateTime::days_in_month(self : ZonedDateTime) -> Int

    Returns the number of days in a month of this datetime.

    ZonedDateTime::days_in_week

    fn ZonedDateTime::days_in_week(self : ZonedDateTime) -> Int

    Returns the number of days in a month of this datetime.

    ZonedDateTime::days_in_year

    fn ZonedDateTime::days_in_year(self : ZonedDateTime) -> Int

    Returns the number of days in a year of this datetime.

    ZonedDateTime::era

    fn ZonedDateTime::era(self : ZonedDateTime) -> String

    Returns the era of this datetime.

    ZonedDateTime::era_year

    fn ZonedDateTime::era_year(self : ZonedDateTime) -> Int

    Returns the year of era of this datetime.

    ZonedDateTime::from_plain

    fn ZonedDateTime::from_plain(datetime : PlainDateTime, zone? : Zone, disambiguation? : Disambiguation) -> ZonedDateTime raise

    Creates a ZonedDateTime from a local calendar date and clock reading. The default time zone is UTC+0. Compatible (the default) chooses the earlier instant in an overlap and shifts forward across a gap. Earlier shifts backward across a gap; Later chooses the later instant in an overlap. Reject raises an error for either case. Adjustments beyond the date range remain unresolved.

    ZonedDateTime::from_plain_datetime

    #deprecated("Use `ZonedDateTime::from_plain` to choose a disambiguation policy")
    fn ZonedDateTime::from_plain_datetime(datetime : PlainDateTime, zone? : Zone) -> ZonedDateTime

    Creates a ZonedDateTime from a PlainDateTime and a time zone. The default time zone is UTC+0. When clocks move backward and a local time occurs twice, uses the first occurrence. When clocks move forward and skip a local time, moves it forward by the gap's duration. Adjustments beyond the date range remain unresolved.

    ZonedDateTime::from_unix_second

    fn ZonedDateTime::from_unix_second(second : Int64, nanosecond? : Int, zone? : Zone) -> ZonedDateTime raise

    Creates a ZonedDateTime from elapsed seconds since the unix epoch and a time zone. The default time zone is UTC+0.

    ZonedDateTime::hour

    fn ZonedDateTime::hour(self : ZonedDateTime) -> Int

    Returns the hour of this datetime.

    ZonedDateTime::in_leap_year

    fn ZonedDateTime::in_leap_year(self : ZonedDateTime) -> Bool

    Checks if this datetime is in a leap year.

    ZonedDateTime::minute

    fn ZonedDateTime::minute(self : ZonedDateTime) -> Int

    Returns the minute of this datetime.

    ZonedDateTime::month

    fn ZonedDateTime::month(self : ZonedDateTime) -> Int

    Returns the month of this datetime.

    ZonedDateTime::months_in_year

    fn ZonedDateTime::months_in_year(self : ZonedDateTime) -> Int

    Returns the number of months in a year of this datetime.

    ZonedDateTime::nanosecond

    fn ZonedDateTime::nanosecond(self : ZonedDateTime) -> Int

    Returns the nanosecond of this datetime.

    ZonedDateTime::of

    fn ZonedDateTime::of(year : Int, month : Int, day : Int, hour? : Int, minute? : Int, second? : Int, nanosecond? : Int, zone? : Zone, disambiguation? : Disambiguation) -> ZonedDateTime raise

    Creates a ZonedDateTime from year, month, day, hour, minute and second. The default time zone is UTC+0. Compatible (the default) chooses the earlier instant in an overlap and shifts forward across a gap. Earlier shifts backward across a gap; Later chooses the later instant in an overlap. Reject raises an error for either case. Adjustments beyond the date range remain unresolved.

    ZonedDateTime::offset

    fn ZonedDateTime::offset(self : ZonedDateTime) -> ZoneOffset

    Returns the time offset of this datetime.

    ZonedDateTime::ordinal

    fn ZonedDateTime::ordinal(self : ZonedDateTime) -> Int

    Returns the ordinal day of year of this datetime.

    ZonedDateTime::output

    #deprecated("`ZonedDateTime::output` is deprecated, use `Show::output` instead.")
    fn ZonedDateTime::output(self : ZonedDateTime, logger : &Logger) -> Unit

    ZonedDateTime::second

    fn ZonedDateTime::second(self : ZonedDateTime) -> Int

    Returns the second of this datetime.

    ZonedDateTime::to_plain_date

    fn ZonedDateTime::to_plain_date(self : ZonedDateTime) -> PlainDate

    Returns the date part of this datetime, without timezone.

    ZonedDateTime::to_plain_date_time

    fn ZonedDateTime::to_plain_date_time(self : ZonedDateTime) -> PlainDateTime

    Returns the datetime part of this datetime, without timezone.

    ZonedDateTime::to_plain_time

    fn ZonedDateTime::to_plain_time(self : ZonedDateTime) -> PlainTime

    Returns the time part of this datetime, without timezone.

    ZonedDateTime::to_repr

    #deprecated("`ZonedDateTime::to_repr` is deprecated, use `@moonbitlang/core/debug.Debug::to_repr` instead.")
    fn ZonedDateTime::to_repr(ZonedDateTime) ->
    Repr

    ZonedDateTime::to_string

    fn ZonedDateTime::to_string(self : ZonedDateTime) -> String

    Returns a string representing this datetime, like "2008-08-08T20:00:00+8:00[Asia/Beijing]"

    ZonedDateTime::to_unix_second

    fn ZonedDateTime::to_unix_second(self : ZonedDateTime) -> Int64

    Returns the elapsed seconds since the unix epoch.

    ZonedDateTime::weekday

    fn ZonedDateTime::weekday(self : ZonedDateTime) -> Weekday

    Returns the weekday of this datetime.

    ZonedDateTime::with_day

    fn ZonedDateTime::with_day(self : ZonedDateTime, day : Int, offset? : OffsetPolicy, disambiguation? : Disambiguation) -> ZonedDateTime raise

    Returns a new datetime with the specified day of the month. Defaults to offset=Prefer and disambiguation=Compatible: retain a valid original offset; otherwise choose the earlier overlap or shift a gap forward.

    ZonedDateTime::with_hour

    fn ZonedDateTime::with_hour(self : ZonedDateTime, hour : Int, offset? : OffsetPolicy, disambiguation? : Disambiguation) -> ZonedDateTime raise

    Returns a new datetime with the specified hour. Defaults to offset=Prefer and disambiguation=Compatible: retain a valid original offset; otherwise choose the earlier overlap or shift a gap forward.

    ZonedDateTime::with_minute

    fn ZonedDateTime::with_minute(self : ZonedDateTime, minute : Int, offset? : OffsetPolicy, disambiguation? : Disambiguation) -> ZonedDateTime raise

    Returns a new datetime with the specified minute. Defaults to offset=Prefer and disambiguation=Compatible: retain a valid original offset; otherwise choose the earlier overlap or shift a gap forward.

    ZonedDateTime::with_month

    fn ZonedDateTime::with_month(self : ZonedDateTime, month : Int, offset? : OffsetPolicy, disambiguation? : Disambiguation) -> ZonedDateTime raise

    Returns a new datetime with the specified month. Defaults to offset=Prefer and disambiguation=Compatible: retain a valid original offset; otherwise choose the earlier overlap or shift a gap forward.

    ZonedDateTime::with_nanosecond

    fn ZonedDateTime::with_nanosecond(self : ZonedDateTime, nanosecond : Int, offset? : OffsetPolicy, disambiguation? : Disambiguation) -> ZonedDateTime raise

    Returns a new datetime with the specified nanosecond. Defaults to offset=Prefer and disambiguation=Compatible: retain a valid original offset; otherwise choose the earlier overlap or shift a gap forward.

    ZonedDateTime::with_ordinal

    fn ZonedDateTime::with_ordinal(self : ZonedDateTime, ordinal : Int, offset? : OffsetPolicy, disambiguation? : Disambiguation) -> ZonedDateTime raise

    Returns a new datetime with the specified ordinal day of the year. Defaults to offset=Prefer and disambiguation=Compatible: retain a valid original offset; otherwise choose the earlier overlap or shift a gap forward.

    ZonedDateTime::with_second

    fn ZonedDateTime::with_second(self : ZonedDateTime, second : Int, offset? : OffsetPolicy, disambiguation? : Disambiguation) -> ZonedDateTime raise

    Returns a new datetime with the specified second. Defaults to offset=Prefer and disambiguation=Compatible: retain a valid original offset; otherwise choose the earlier overlap or shift a gap forward.

    ZonedDateTime::with_year

    fn ZonedDateTime::with_year(self : ZonedDateTime, year : Int, offset? : OffsetPolicy, disambiguation? : Disambiguation) -> ZonedDateTime raise

    Returns a new datetime with the specified year. Defaults to offset=Prefer and disambiguation=Compatible: retain a valid original offset; otherwise choose the earlier overlap or shift a gap forward.

    ZonedDateTime::year

    fn ZonedDateTime::year(self : ZonedDateTime) -> Int

    Returns the year of this datetime.

    ZonedDateTime::zone

    fn ZonedDateTime::zone(self : ZonedDateTime) -> Zone

    Returns the time zone of this datetime.

    date_time

    fn date_time(year : Int, month : Int, day : Int, hour? : Int, minute? : Int, second? : Int, nanosecond? : Int, zone? : Zone, disambiguation? : Disambiguation) -> ZonedDateTime raise

    Creates a ZonedDateTime from year, month, day, hour, minute, second and a time zone. The default time zone is UTC+0. Uses the same disambiguation policy as ZonedDateTime::of.

    fixed_zone

    fn fixed_zone(id : String, offset_seconds : Int, abbrev? : String, dst? : Bool) -> Zone raise

    Creates a time zone with fixed offset from time zone id and offset seconds.

    local_zone

    fn local_zone() -> Zone raise

    unix

    fn unix(second : Int64, nanosecond? : Int, zone? : Zone) -> ZonedDateTime raise

    Creates a ZonedDateTime from elapsed seconds since the unix epoch and a time zone. The default time zone is UTC+0.

    utc_offset

    let utc_offset : ZoneOffset

    UTC+0 offset.

    utc_zone

    let utc_zone : Zone

    UTC time zone.