#core package

    Calendar and clock primitives with no time zone awareness. Import connect0459/almanac/core for Weekday, WeekdaySet, Month, IsoWeek, NaiveWeek, NaiveDate, NaiveTime, TimeDelta, and NaiveDateTime. The tz package layers a time zone on top of NaiveDateTime.

    #Key types

    TypeDescription
    WeekdayCyclic day-of-week enum (Mon..Sun)
    WeekdaySetAn immutable set of Weekday values, stored as a bitset
    MonthCyclic month enum (Jan..Dec)
    IsoWeekISO 8601 week-numbering year and week
    NaiveDateA proleptic Gregorian calendar date, no time zone
    NaiveWeekThe week containing a date, under a configurable first day of the week
    NaiveDateDaysIterator / NaiveDateWeeksIteratorLazy, bounded, double-ended iterators over successive dates from NaiveDate::iter_days/iter_weeks
    WeekdaySetIteratorDouble-ended iterator over a WeekdaySet's members in cyclic weekday order from a chosen start, from WeekdaySet::iter_from
    NaiveTimeA time of day, precise to the nanosecond, with leap-second support
    TimeDeltaA signed duration, precise to the nanosecond
    NaiveDateTimeA NaiveDate and NaiveTime combined into one zone-less instant
    YearCe / ClockHour12Named results of year_ce() and hour12(): is_ce()/year() and is_pm()/hour(), so the meaning of each part is in its name rather than its position in a tuple
    RoundingErrorWhy a round/round_up/truncate call failed: InvalidGranularity (zero or negative), MixedGranularity (a whole-second part combined with a sub-second remainder, e.g. 1.5 seconds), or OutOfRange (the result would leave the type's representable range)

    NaiveDate (1970-01-01), NaiveTime (midnight), NaiveDateTime (the Unix epoch), TimeDelta (zero) and WeekdaySet (empty) implement Default. Struct-valued constants are exposed as functions (NaiveTime::midnight(), NaiveDateTime::unix_epoch(), TimeDelta::zero()) because MoonBit's const is limited to primitive types.

    Every value type above (all but the two iterators) implements Hash consistently with its Eq, so values can be Map keys. NaiveWeek hashes by first_day() alone, matching its Eq: two weeks anchored on different dates of the same calendar week are equal and hash equally.

    #Quick start

    Constructing a date and reading its calendar fields:

    ///|
    test {
    let date = @core.NaiveDate::from_ymd(2024, 2, 29).unwrap()
    assert_eq(date.month(), @core.Feb)
    assert_eq(date.weekday(), @core.Thu)
    assert_eq(@core.NaiveDate::from_ymd(2023, 2, 29), None)
    }

    TimeDelta::round/truncate snap a duration to a multiple of a granularity: truncate always moves toward zero, while round breaks an exact halfway tie by moving away from zero:

    ///|
    test {
    let half_hour = @core.TimeDelta::minutes(30L).unwrap()
    let hour = @core.TimeDelta::hours(1L).unwrap()
    assert_eq(half_hour.round(hour), Ok(hour))
    assert_eq(half_hour.truncate(hour), Ok(@core.TimeDelta::zero()))
    }

    NaiveDateTime::round/truncate measure that granularity since the Unix epoch, so truncating a datetime before the epoch moves it forward in time, toward the epoch, not further into the past:

    ///|
    test {
    let dt = @core.NaiveDateTime::new(
    @core.NaiveDate::from_ymd(1969, 12, 31).unwrap(),
    @core.NaiveTime::from_hms(14, 45, 30).unwrap(),
    )
    let truncated = dt.truncate(@core.TimeDelta::hours(1L).unwrap()).unwrap()
    assert_eq(truncated.time(), @core.NaiveTime::from_hms(15, 0, 0).unwrap())
    }

    #API reference

    #Free functions

    FunctionSignatureDescription
    is_leap_year(Int)-> BoolStandard 4/100/400 leap-year rule


    #Weekday

    Mon, Tue, Wed, Thu, Fri, Sat, Sun.

    MethodSignatureDescription
    succ()-> SelfNext day, wrapping Sun to Mon
    add_days(n)(Int) -> SelfThe weekday n days later (earlier for negative n), wrapping around the week; total for every Int
    pred()-> SelfPrevious day, wrapping Mon to Sun
    number_from_monday()-> Int1-based, Mon is 1
    number_from_sunday()-> Int1-based, Sun is 1
    num_days_from_monday()-> Int0-based, Mon is 0
    num_days_from_sunday()-> Int0-based, Sun is 0
    days_since(Weekday)-> IntDays elapsed since other, counting forward
    name()-> StringEnglish name, e.g. "Monday"
    Weekday::from_number_from_monday(Int)-> Weekday?Inverse of number_from_monday(); None outside 1..=7
    Weekday::from_number_from_sunday(Int)-> Weekday?Inverse of number_from_sunday(); None outside 1..=7
    Weekday::from_num_days_from_monday(Int)-> Weekday?Inverse of num_days_from_monday(); None outside 0..=6
    Weekday::from_num_days_from_sunday(Int)-> Weekday?Inverse of num_days_from_sunday(); None outside 0..=6
    Weekday::from_name(String)-> Weekday?The weekday for a full English name ("Monday") or three-letter abbreviation ("Mon"), ignoring ASCII letter case; None for anything else (a prefix, "Tues", surrounding whitespace, non-ASCII text)

    Naming rule: number_from_* counts from 1 (ISO 8601 for Monday), and num_days_from_* counts whole days elapsed since that start day, from 0; each has a from_* inverse that returns None outside its range.

    Weekday also implements Eq and Show (renders name()). It deliberately has no Compare: a weekday ordering depends on which day starts the week, so use num_days_from_monday/num_days_from_sunday/days_since to compare with an explicit starting day.


    #WeekdaySet

    An immutable set of Weekday values. Every mutating-looking operation (insert, remove) returns a new set rather than changing self in place.

    MethodSignatureDescription
    WeekdaySet::empty()-> SelfThe empty set
    WeekdaySet::all()-> SelfThe set containing all seven weekdays
    WeekdaySet::single(Weekday)-> SelfA set containing exactly one weekday
    WeekdaySet::from_array(Array[Weekday])-> SelfA set containing exactly the given weekdays
    single_day()-> Weekday?The one member, if the set has exactly one; None otherwise
    insert(Weekday)-> SelfThe set with a weekday added
    remove(Weekday)-> SelfThe set with a weekday removed
    contains(Weekday)-> BoolWhether a weekday is a member
    is_subset(Self)-> BoolWhether every member of self is also in other
    union(Self)-> SelfMembers in either set
    intersection(Self)-> SelfMembers in both sets
    difference(Self)-> SelfMembers in self but not in other
    symmetric_difference(Self)-> SelfMembers in exactly one of the two sets
    first()-> Weekday?The earliest member, starting from Mon; None if empty
    last()-> Weekday?The latest member, starting from Sun; None if empty
    is_empty()-> BoolWhether the set has no members
    length()-> IntThe number of members
    to_array()-> Array[Weekday]Members in Mon..Sun order
    iter(start? : Weekday)-> Iter[Weekday]Members in cyclic order from start (default Mon, matching to_array()), wrapping from Sun to Mon; a start that is not a member begins at the next member. A standard Iter, so for day in set.iter(start=Sun) and adapters work (for day in set does not: for needs a zero-argument iter())
    iter_from(start : Weekday)-> WeekdaySetIteratorThe same order as a double-ended iterator with next(), next_back(), length() and iter(); the ends converge without skipping or repeating a weekday

    WeekdaySet also implements Eq, Hash and Show; it deliberately has no Compare, since an order over sets would only reflect the bit layout (use is_subset for the meaningful relation), rendering the members' short names in Mon..Sun order ([Mon, Fri], empty is []).


    #Month

    Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec.

    MethodSignatureDescription
    succ()-> SelfNext month, wrapping Dec to Jan
    add_months(n)(Int) -> SelfThe month n months later (earlier for negative n), wrapping around the year; total for every Int
    pred()-> SelfPrevious month, wrapping Jan to Dec
    number()-> Int1-based, Jan is 1
    name()-> StringFull English name, e.g. "February"
    num_days(Int)-> IntNumber of days in this month for the given year
    Month::from_number(Int)-> Month?Inverse of number(); None outside 1..=12
    Month::from_name(String)-> Month?The month for a full English name ("January") or three-letter abbreviation ("Jan"), ignoring ASCII letter case; None for anything else (a prefix, "Sept", surrounding whitespace, non-ASCII text)

    Month also implements Eq, Compare (Jan < ... < Dec) and Show (renders name()).


    #IsoWeek

    MethodSignatureDescription
    year()-> IntISO 8601 week-numbering year (can differ from the calendar year near a year boundary)
    week()-> Int1-based week number within that year
    week0()-> Int0-based week number

    IsoWeek also implements Eq, Compare (</<=/>/>= via compare) and Show, rendering YYYY-Www (2015-W38); a year outside 0..=9999 gets an explicit sign (+10000-W01).


    #NaiveDate

    A proleptic Gregorian calendar date. Constructors are Option-returning: an invalid combination reports None rather than clamping.

    MethodSignatureDescription
    NaiveDate::from_ymd(Int, Int, Int)-> Self?From year, month, day; None for an invalid month or day, or a date outside the representable range
    NaiveDate::from_yo(Int, Int)-> Self?From year and ordinal day (1..=365/366); None outside the representable range
    NaiveDate::from_isoywd(Int, Int, Weekday)-> Self?From ISO week-numbering year, week, and weekday; None outside the representable range
    NaiveDate::from_weekday_of_month(Int, Int, Weekday, Int)-> Self?The n-th (1-indexed) occurrence of a weekday in a month, e.g. the 2nd Friday of March 2017; None if n isn't positive or that occurrence doesn't exist
    year()-> IntCalendar year
    month()-> MonthCalendar month
    day()-> IntDay of month
    ymd()-> (Int, Month, Int)Year, month and day of month together
    ordinal()-> IntDay of year, 1-based
    month0() / day0() / ordinal0()-> IntThe zero-based forms of the month (0..=11), day of month (0..=30) and day of year (0..=365)
    year_ce()-> YearCeThe year as a Common Era flag (is_ce()) and a positive year number (year()): 2024 CE, and 1 BCE for year 0, 2 BCE for year -1
    num_days_in_month()-> IntLength of this date's month, honoring leap years
    abs_diff_days(Self)-> Int64Non-negative number of days between two dates, in either order; equals signed_duration_since(other).abs().num_days()
    weekday()-> WeekdayDay of week
    iso_week()-> IsoWeekISO 8601 week-numbering year and week
    leap_year()-> BoolWhether this date's year is a leap year
    with_year(Int)-> Self?Same month/day in a different year; None if that combination is invalid (e.g. Feb 29 into a non-leap year)
    with_month(Int)-> Self?Same year/day in a different month; None if the day doesn't exist in that month
    with_day(Int)-> Self?Same year/month with a different day
    with_ordinal(Int)-> Self?Same year with a different ordinal day
    with_month0(Int) / with_day0(Int) / with_ordinal0(Int)-> Self?As with_month/with_day/with_ordinal, taking a zero-based value
    succ()-> SelfThe next day
    pred()-> SelfThe previous day
    add_days(Int)-> SelfShift forward (or back, if negative) by a day count
    sub_days(Int)-> SelfShift backward by a day count
    add_signed(TimeDelta)-> SelfShift forward by the duration's whole days (sub-day remainder truncated toward zero); aborts if out of range
    sub_signed(TimeDelta)-> SelfShift backward by the duration's whole days; aborts if out of range
    checked_add_signed(TimeDelta) / checked_sub_signed(TimeDelta)-> Self?As add_signed/sub_signed, but None if out of range
    signed_duration_since(Self)-> TimeDeltaWhole-day duration from other to this date
    and_time(NaiveTime)-> NaiveDateTimeCombine with a time of day
    and_hms(Int, Int, Int)-> NaiveDateTime?Combine with hour:min:sec; None if a component is out of range
    and_hms_milli(Int, Int, Int, Int)-> NaiveDateTime?As and_hms, plus milliseconds
    and_hms_micro(Int, Int, Int, Int)-> NaiveDateTime?As and_hms, plus microseconds
    and_hms_nano(Int, Int, Int, Int)-> NaiveDateTime?As and_hms, plus nanoseconds (>= 1_000_000_000 encodes a leap second)
    epoch_days()-> IntDays since the Unix epoch (1970-01-01 is 0)
    NaiveDate::from_epoch_days(Int)-> NaiveDate?Inverse of epoch_days(); None if out of range
    num_days_from_ce()-> IntDays since the Common Era (0001-01-01 is 1); also available on NaiveDateTime and DateTime, whereas epoch_days()/from_epoch_days exist only here, because a count of days since the epoch would be ambiguous between a date and an instant
    NaiveDate::from_num_days_from_ce(Int)-> NaiveDate?Inverse of num_days_from_ce(); None if out of range
    add_months(Int)-> SelfShift by whole months, clamping the day of month to the target month's length
    sub_months(Int)-> SelfShift backward by whole months, with the same clamping
    checked_succ()-> Self?The next day; None at the last representable date
    checked_pred()-> Self?The previous day; None at the first representable date
    checked_add_days(Int) / checked_sub_days(Int)-> Self?As add_days/sub_days, but None if out of range
    checked_add_months(Int) / checked_sub_months(Int)-> Self?As add_months/sub_months, but None if out of range
    add_years(Int) / sub_years(Int)-> SelfShift by whole years, clamping February 29 to February 28 in a non-leap year (same as add_months(12 * years))
    checked_add_years(Int) / checked_sub_years(Int)-> Self?As add_years/sub_years, but None if out of range
    week(Weekday)-> NaiveWeekThe calendar week containing this date, with weeks starting on the given weekday
    years_since(Self)-> Int?Full elapsed calendar years from other to self (a year counts once the month and day have both recurred); None if self is before other
    quarter()-> IntCalendar quarter, 1..=4
    iter_days()-> NaiveDateDaysIteratorLazy, bounded, double-ended iterator over successive dates one day apart, starting from self
    iter_weeks()-> NaiveDateWeeksIteratorLazy, bounded, double-ended iterator over successive dates one week apart, starting from self

    NaiveDate also implements Eq, Compare (</<=/>/>= via compare) and Show, rendering YYYY-MM-DD (2024-01-02); a year outside 0..=9999 gets an explicit sign (-0001-12-31, +10000-01-01).


    #NaiveDateDaysIterator / NaiveDateWeeksIterator

    Returned by NaiveDate::iter_days/iter_weeks. Both are lazy and double-ended: next() advances from the front, next_back() from the back, and they converge without skipping or repeating a date. Both are bounded above by a conservative, round practical limit, +275760-09-13 (matching the well-known ECMAScript Date representable range) — not NaiveDate's actual much larger overflow-safe range — reaching and including that bound if the iterator gets that far; a date already past it yields nothing. Each also has iter(), returning a standard Iter[NaiveDate] that shares the iterator's state, so for date in start.iter_days() { ... } works directly and adapters are available through it (start.iter_days().iter().take(7).map(...).collect()); the iterator types themselves cannot be Iter values, since MoonBit's Iter is a concrete closure-based type rather than a trait.

    MethodSignatureDescription
    next()-> NaiveDate?The next date from the front, or None once exhausted
    next_back()-> NaiveDate?The next date from the back, or None once exhausted
    length()-> IntThe number of dates (NaiveDateDaysIterator) or weekly steps (NaiveDateWeeksIterator) remaining


    #NaiveWeek

    The week containing a NaiveDate, under a configurable first day of the week (via NaiveDate::week). Distinct from IsoWeek, which is always Monday-based and tied to the ISO 8601 week-numbering year. Two NaiveWeeks are equal (and compare) by the calendar week they denote — first_day() alone — regardless of which date within it was used to construct them.

    MethodSignatureDescription
    first_day()-> NaiveDateThe first day of the week
    last_day()-> NaiveDateThe last day of the week, six days after first_day()
    days()-> Array[NaiveDate]All seven days of the week, from first_day() to last_day()

    NaiveWeek also implements Eq and Compare (</<=/>/>= via compare).


    #NaiveTime

    A time of day, precise to the nanosecond. Constructors are Option-returning. Supports leap seconds: a nanosecond component >= 1_000_000_000 at second() == 59 represents one — second() never itself reports 60.

    MethodSignatureDescription
    NaiveTime::from_hms(Int, Int, Int)-> Self?From hour, minute, second
    NaiveTime::midnight()-> SelfThe start of the day, 00:00:00, the earliest time of day; also NaiveTime's Default
    NaiveTime::from_hms_milli(Int, Int, Int, Int)-> Self?With a millisecond component
    NaiveTime::from_hms_micro(Int, Int, Int, Int)-> Self?With a microsecond component
    NaiveTime::from_hms_nano(Int, Int, Int, Int)-> Self?With a nanosecond component (0..=1_999_999_999, the upper half representing a leap second)
    NaiveTime::from_num_seconds_from_midnight(Int, Int)-> Self?From a seconds-since-midnight count plus a nanosecond component
    hour()-> IntHour, 0..=23
    minute()-> IntMinute, 0..=59
    second()-> IntSecond, 0..=59 (never 60; see leap seconds above)
    hms()-> (Int, Int, Int)Hour, minute and second together (a leap second reports second 59, as second() does)
    nanosecond()-> IntNanosecond component, 0..=1_999_999_999
    hour12()-> ClockHour1212-hour clock hour (hour()) and PM flag (is_pm()), wrapping midnight/noon to 12
    round_subsecs(Int) / truncate_subsecs(Int)-> SelfRound (ties up) or truncate to a number of fractional-second digits (0..=9; other values abort). A carry wraps past the end of the day to midnight and the day carry is discarded (NaiveDateTime::round_subsecs moves the date forward instead). A time with no digits beyond that count is returned unchanged, leap second included (9 is the identity); otherwise a leap second is folded into the following second
    num_seconds_from_midnight()-> IntSeconds elapsed since midnight
    overflowing_add_signed(TimeDelta)-> (Self, Int64)Add a duration, wrapping at midnight; also reports the number of days crossed
    overflowing_sub_signed(TimeDelta)-> (Self, Int64)Subtract a duration, with the same wrapping and day-count report
    wrapping_add_signed(TimeDelta) / wrapping_sub_signed(TimeDelta)-> SelfAs overflowing_add_signed/overflowing_sub_signed, discarding the day count
    with_hour(Int)-> Self?Same minute/second/nanosecond in a different hour; None if outside 0..=23
    with_minute(Int)-> Self?Same hour/second/nanosecond in a different minute; None if outside 0..=59
    with_second(Int)-> Self?Same hour/minute/nanosecond in a different second; None if outside 0..=59
    with_nanosecond(Int)-> Self?Same hour/minute/second with a different nanosecond component; None if outside 0..=1_999_999_999
    signed_duration_since(Self)-> TimeDeltaThe signed duration from other to self, with no day carry; a leap second is treated as coinciding with the prior non-leap second until time moves away from it

    NaiveTime also implements Eq, Compare (</<=/>/>= via compare) and Show, rendering HH:MM:SS plus, only when the nanoseconds are nonzero, the fewest of 3, 6 or 9 fractional digits that represent them exactly (.500, .123456, .000000789); a leap second is rendered with second 60.


    #TimeDelta

    A signed duration, precise to the nanosecond. Constructors and checked arithmetic are Option-returning, reporting None on overflow or invalid input.

    MethodSignatureDescription
    TimeDelta::weeks(Int64)-> Self?Whole weeks
    TimeDelta::days(Int64)-> Self?Whole days
    TimeDelta::hours(Int64)-> Self?Whole hours
    TimeDelta::minutes(Int64)-> Self?Whole minutes
    TimeDelta::seconds(Int64)-> Self?Whole seconds
    TimeDelta::milliseconds(Int64)-> Self?Whole milliseconds
    TimeDelta::microseconds(Int64)-> Self?Whole microseconds
    TimeDelta::nanoseconds(Int64)-> Self?Whole nanoseconds
    TimeDelta::new(Int64, Int)-> Self?Whole seconds plus a nanosecond remainder in 0..=999_999_999 (the sign lives in the seconds: new(-1, 500_000_000) is minus half a second); None if the remainder is out of range or the result is out of range
    TimeDelta::from_seconds_double(Double)-> Self?From fractional seconds, rounded to the nearest nanosecond (an exact half-nanosecond tie goes away from zero, so 0.3 is exactly 300 000 000 ns); None for NaN, an infinity or an out-of-range value. Nanosecond precision holds only while the whole-second part is below about 9 million seconds, a Double limit
    TimeDelta::zero()-> SelfThe zero-length duration
    TimeDelta::min_value()-> SelfThe most negative representable duration, exactly -9_223_372_036_854_774 seconds
    TimeDelta::max_value()-> SelfThe most positive representable duration, exactly 9_223_372_036_854_774 seconds; the range is symmetric, so neg() and abs() never leave it
    num_weeks()-> Int64Whole weeks, truncated toward zero
    num_days()-> Int64Whole days, truncated toward zero
    num_hours()-> Int64Whole hours, truncated toward zero
    num_minutes()-> Int64Whole minutes, truncated toward zero
    num_seconds()-> Int64Whole seconds, truncated toward zero
    num_milliseconds()-> Int64Whole milliseconds, truncated toward zero; always succeeds
    num_microseconds()-> Int64?Whole microseconds, truncated toward zero; None if it overflows Int64
    num_nanoseconds()-> Int64?Whole nanoseconds; None if it overflows Int64
    subsec_nanoseconds()-> IntNanosecond remainder, signed to match the overall duration
    subsec_milliseconds()-> Intsubsec_nanoseconds() in whole milliseconds
    subsec_microseconds()-> Intsubsec_nanoseconds() in whole microseconds
    as_seconds_double()-> DoubleTotal length in fractional seconds, as a 64-bit float; loses precision for a very large duration, never fails
    as_minutes_double() / as_hours_double()-> DoubleTotal length in fractional minutes / hours, as a 64-bit float; same precision caveat
    add(TimeDelta)-> SelfSum; aborts on overflow
    sub(TimeDelta)-> SelfDifference; aborts on overflow
    mul(Int)-> SelfScale by an integer scalar; aborts on overflow
    div(Int)-> SelfDivide by an integer scalar, truncated toward zero; aborts if the scalar is zero
    TimeDelta::sum(Array[TimeDelta])-> SelfTotal of an array, zero() when empty; aborts only if the true total is out of range (see checked_sum)
    checked_add(TimeDelta) / checked_sub(TimeDelta)-> Self?As add/sub, but None on overflow
    checked_mul(Int)-> Self?As mul, but None on overflow
    checked_div(Int)-> Self?As div, but None if the scalar is zero
    TimeDelta::checked_sum(Array[TimeDelta])-> Self?As sum, but None if the true total is out of range; unlike folding with checked_add, independent of order, so a partial sum that would leave the range does not spoil a representable total
    neg()-> SelfNegation
    + / - / unary -Add/Sub/NegOperator forms of add, sub and neg; + and - abort on overflow like add/sub
    abs()-> SelfAbsolute value
    is_zero()-> BoolWhether this duration is exactly zero
    round(TimeDelta)-> Result[Self, RoundingError]Round to the nearest multiple of a granularity, ties breaking away from zero; Err(InvalidGranularity) if the granularity is zero or negative, Err(MixedGranularity) if it mixes a whole-second part with a sub-second remainder (e.g. 1.5 seconds — every named duration unit is either purely sub-second or a whole-second-or-larger multiple), Err(OutOfRange) if the result would leave the representable range
    truncate(TimeDelta)-> Result[Self, RoundingError]Truncate toward zero to the nearest multiple of a granularity; same granularity restriction as round
    round_up(TimeDelta)-> Result[Self, RoundingError]Round up (toward positive infinity) to a multiple of a granularity: unchanged if already a multiple, otherwise the next one above (for a negative duration that is toward zero, equal to truncate); Err with the same reasons as round

    TimeDelta also implements Eq, Compare (</<=/>/>= via compare) and Show. Show renders compactly: a leading - for a negative value, then hours/minutes/seconds (1h2m3.5s) with hours as the largest unit (never days) and trailing fractional zeros trimmed; units between the largest and the seconds are kept even when zero (1h0m0s); a duration under one second uses ns/us/ms (1.5ms); zero is 0s. format's parse_duration reads this form back.


    #NaiveDateTime

    A NaiveDate and NaiveTime combined into one zone-less instant.

    MethodSignatureDescription
    NaiveDateTime::new(NaiveDate, NaiveTime)-> SelfCompose a date and a time of day
    NaiveDateTime::from_ymd_hms(Int, Int, Int, Int, Int, Int)-> Self?From year, month, day, hour, minute and second; None if any component is out of range
    NaiveDateTime::unix_epoch()-> SelfThe Unix epoch, 1970-01-01 00:00:00 (timestamp zero); also NaiveDateTime's Default
    year() / month() / day() / ordinal() / weekday() / iso_week() / leap_year()-> Int / Month / Int / Int / Weekday / IsoWeek / BoolThe date's components, as on NaiveDate
    hour() / minute() / second() / nanosecond()-> IntThe time's components, as on NaiveTime (nanosecond() >= 1_000_000_000 encodes a leap second)
    ymd() / hms()-> (Int, Month, Int) / (Int, Int, Int)The date and time components together, as on NaiveDate/NaiveTime
    years_since(Self)-> Int?Full calendar years elapsed from base, comparing the dates and ignoring the time of day; None if self is before base
    month0() / day0() / ordinal0() / quarter() / num_days_in_month() / num_days_from_ce()-> IntThe zero-based month/day/ordinal, the quarter (1..=4), the month's length and the Common Era day count, as on NaiveDate
    year_ce()-> YearCeThe year as a Common Era flag and positive year number, as on NaiveDate
    hour12()-> ClockHour12The 12-hour clock as a PM flag and an hour in 1..=12, as on NaiveTime
    num_seconds_from_midnight()-> IntSeconds since midnight, as on NaiveTime
    with_date(NaiveDate) / with_time(NaiveTime)-> SelfReplace the date or the time of day, keeping the other; total
    with_year(Int) / with_month(Int) / with_day(Int) / with_ordinal(Int)-> Self?Replace one date component, keeping the time of day; None if the result is not a valid date
    with_month0(Int) / with_day0(Int) / with_ordinal0(Int)-> Self?As with_month/with_day/with_ordinal, taking a zero-based value, keeping the time of day
    with_hour(Int) / with_minute(Int) / with_second(Int) / with_nanosecond(Int)-> Self?Replace one time component, keeping the date and every other time field (including a leap second); None if out of range
    NaiveDateTime::from_timestamp(Int64, Int)-> Self?From a Unix timestamp (whole seconds) plus a nanosecond component (0..=1_999_999_999)
    NaiveDateTime::from_timestamp_millis(Int64)-> Self?From a Unix timestamp in whole milliseconds
    NaiveDateTime::from_timestamp_micros(Int64)-> Self?From a Unix timestamp in whole microseconds
    NaiveDateTime::from_timestamp_nanos(Int64)-> Self?From a Unix timestamp in whole nanoseconds
    date()-> NaiveDateThe date component
    time()-> NaiveTimeThe time-of-day component
    timestamp()-> Int64Unix timestamp in whole seconds, truncated toward negative infinity
    timestamp_millis()-> Int64Unix timestamp in whole milliseconds; always succeeds
    timestamp_micros()-> Int64?Unix timestamp in whole microseconds; None if it overflows Int64 (a date far from the epoch)
    timestamp_nanos()-> Int64?Unix timestamp in whole nanoseconds; same overflow caveat
    timestamp_subsec_nanos()-> IntNanosecond component of this instant
    timestamp_subsec_millis()-> IntThat component in whole milliseconds
    timestamp_subsec_micros()-> IntThat component in whole microseconds
    add_signed(TimeDelta)-> SelfAdvance by a signed duration, propagating any day overflow into the date
    sub_signed(TimeDelta)-> SelfMove back by a signed duration
    add_months(Int)-> SelfShift the date by whole months, keeping the time of day
    add_years(Int) / sub_years(Int)-> SelfShift the date by whole years, keeping the time of day; February 29 clamps to February 28 in a non-leap year
    sub_months(Int)-> SelfShift the date backward by whole months
    add_days(Int)-> SelfShift the date by a day count, keeping the time of day
    sub_days(Int)-> SelfShift the date backward by a day count
    add_seconds(Int64) / sub_seconds(Int64)-> SelfShift by a whole number of seconds (e.g. to apply a UTC offset), like add_signed with the same seconds: a nonzero shift follows its leap-second rule, a zero shift changes nothing
    checked_add_seconds(Int64) / checked_sub_seconds(Int64)-> Self?As add_seconds/sub_seconds, but None if the date is out of range
    checked_add_signed(TimeDelta) / checked_sub_signed(TimeDelta)-> Self?As add_signed/sub_signed, but None if the date is out of range
    checked_add_days(Int) / checked_sub_days(Int)-> Self?As add_days/sub_days, but None if out of range
    checked_add_months(Int) / checked_sub_months(Int)-> Self?As add_months/sub_months, but None if out of range
    checked_add_years(Int) / checked_sub_years(Int)-> Self?As add_years/sub_years, but None if out of range

    An abort cannot be recovered from in MoonBit, so it is a contract violation by the caller: every function that can abort names the checked_* (or other non-aborting) form in its documentation, and a caller that cannot guarantee the precondition uses that form. Ordering follows one rule: a type implements Compare only where there is a single natural total order that every user agrees on (chronological for times and dates, magnitude for TimeDelta, calendar-year order for Month). A Weekday order depends on the locale's first day, a WeekdaySet order would only reflect its bit layout, and FixedOffset, Utc and the zone types have no such order, so none of them implement it; compare FixedOffset values through local_minus_utc() when that is wanted. Trait coverage follows one rule across the packages: every public value type implements Eq and Debug (a structural dump for diagnostics and assert_eq failures), while Show is reserved for types with a canonical text form and a parser that reads it back (parse_*_default, parse_duration, parse_fixed_offset); types without one, such as NaiveWeek, LocalTimeType, PosixTz, TransitionBounds and MappedLocalTime, have Debug only. The iterators are the one stateful kind of value: next() and next_back() advance the iterator in place, iter() does not advance it but returns an Iter sharing its state, and NaiveDate::iter_days/iter_weeks and WeekdaySet::iter_from return a fresh iterator on every call, leaving the date or set unchanged. Floating-point conversions of TimeDelta are Double only: as_seconds_double/as_minutes_double/as_hours_double read a duration out, and from_seconds_double builds one from fractional seconds; there is no Float form, since 32 bits cannot hold whole seconds beyond a few months exactly. Month types follow one rule: accessors return the typed Month (month(), ymd()), with month().number() as the one-based number and month0() as the zero-based one, while numeric inputs (from_ymd, with_month, NaiveDate::from_yo) are plain Ints that are validated and rejected with None when out of range. So ymd() does not feed from_ymd directly; convert the month with number(). succ and pred share their names across types but not their edge behavior: on Month and Weekday, which are cyclic, they wrap around (Dec to Jan, Sun to Mon), while on NaiveDate they abort at the ends of the representable range, with checked_succ/checked_pred returning None there. NaiveTime arithmetic has its own vocabulary, wrapping_* and overflowing_* as integer arithmetic has, instead of add_signed and checked_add_signed: a time of day cannot leave its range, it wraps at midnight, so there is nothing to abort on or to return None for. wrapping_* discards the number of days crossed and overflowing_* reports it. Integer widths follow one rule: a count of fixed-length time (seconds, milliseconds, microseconds, nanoseconds, timestamps, and the TimeDelta unit constructors) or a difference that can exceed Int (NaiveDate::abs_diff_days) is Int64; a calendar step (add_days, add_months, add_years), a calendar or clock field, a sub-second component within one second, and a scalar multiplier or divisor are Int.

    The non-checked arithmetic on NaiveDate and NaiveDateTime (succ, pred, add_*, sub_*) aborts if the result falls outside the representable date range (about ±5.87 million years around the epoch) rather than wrapping into an invalid date; use the checked_* forms to get None instead. | signed_duration_since(Self) | -> TimeDelta | The signed duration from other to self | | round(TimeDelta) | -> Result[Self, RoundingError] | Round to the nearest multiple of a granularity since the Unix epoch, ties breaking away from the epoch; see TimeDelta::round for which granularities are supported | | truncate(TimeDelta) | -> Result[Self, RoundingError] | Truncate toward the Unix epoch to the nearest multiple of a granularity; a datetime before the epoch is truncated forward in time (see Quick start above), never further into the past | | round_subsecs(Int) / truncate_subsecs(Int) | -> Result[Self, RoundingError] / -> Self | Round or truncate to a number of fractional-second digits (0..=9; other values abort), with the tie-breaking and epoch direction of round/truncate; round_subsecs fails with OutOfRange if rounding up leaves the range. A datetime with no digits beyond that count is returned unchanged, leap second included; otherwise a leap second folds into the following second | | round_up(TimeDelta) | -> Result[Self, RoundingError] | Round up (toward positive infinity) to the next multiple of a granularity since the Unix epoch, unchanged if already a multiple; a datetime before the epoch moves toward the epoch; Err for a rejected granularity, or Err(OutOfRange) if the result would leave NaiveDate's range |

    NaiveDateTime also implements Eq, Compare (</<=/>/>= via compare) and Show, rendering the date and time joined by a space (2024-01-02 13:45:06.500).

    ClockHour12

    pub struct ClockHour12 {
    // private fields
    } derive(Eq, Hash,
    Debug
    )

    An hour on a 12-hour clock: whether it is PM (is_pm) and the hour, 1..=12, where midnight and noon read 12. See NaiveTime::hour12.

    ClockHour12::equal

    fn ClockHour12::equal(ClockHour12, ClockHour12) -> Bool

    ClockHour12::hash

    fn ClockHour12::hash(self : ClockHour12) -> Int

    ClockHour12::hash_combine

    fn ClockHour12::hash_combine(ClockHour12, Hasher) -> Unit

    ClockHour12::hour

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

    The hour on the 12-hour clock, 1..=12.

    ClockHour12::is_pm

    fn ClockHour12::is_pm(self : ClockHour12) -> Bool

    Whether the hour is in the afternoon (12:00 and later on a 24-hour clock).

    ClockHour12::not_equal

    fn ClockHour12::not_equal(x : ClockHour12, y : ClockHour12) -> Bool

    IsoWeek

    pub struct IsoWeek {
    // private fields
    } derive(Compare, Eq, Hash,
    Debug
    )

    An ISO 8601 week date's year and week number. The ISO year may differ from the calendar year of any date that falls in it (see NaiveDate::iso_week).
    impl Show for IsoWeek

    IsoWeek::compare

    fn IsoWeek::compare(IsoWeek, IsoWeek) -> Int

    IsoWeek::equal

    fn IsoWeek::equal(IsoWeek, IsoWeek) -> Bool

    IsoWeek::hash

    fn IsoWeek::hash(self : IsoWeek) -> Int

    IsoWeek::hash_combine

    fn IsoWeek::hash_combine(IsoWeek, Hasher) -> Unit

    IsoWeek::not_equal

    fn IsoWeek::not_equal(x : IsoWeek, y : IsoWeek) -> Bool

    IsoWeek::op_ge

    fn IsoWeek::op_ge(x : IsoWeek, y : IsoWeek) -> Bool

    IsoWeek::op_gt

    fn IsoWeek::op_gt(x : IsoWeek, y : IsoWeek) -> Bool

    IsoWeek::op_le

    fn IsoWeek::op_le(x : IsoWeek, y : IsoWeek) -> Bool

    IsoWeek::op_lt

    fn IsoWeek::op_lt(x : IsoWeek, y : IsoWeek) -> Bool

    IsoWeek::output

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

    IsoWeek::to_repr

    IsoWeek::to_string

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

    IsoWeek::week

    fn IsoWeek::week(self : IsoWeek) -> Int

    The 1-based ISO 8601 week number.

    IsoWeek::week0

    fn IsoWeek::week0(self : IsoWeek) -> Int

    The 0-based ISO 8601 week number.

    IsoWeek::year

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

    The ISO 8601 week-numbering year.

    Month

    pub(all) enum Month {
    Jan
    Feb
    Mar
    Apr
    May
    Jun
    Jul
    Aug
    Sep
    Oct
    Nov
    Dec
    } derive(Compare, Eq, Hash,
    Debug
    )

    A month of the year.
    impl Show for Month

    Month::add_months

    fn Month::add_months(self : Month, n : Int) -> Month

    The month n months after self (before it, for a negative n), wrapping around the year in either direction.

    Month::compare

    fn Month::compare(Month, Month) -> Int

    Month::equal

    fn Month::equal(Month, Month) -> Bool

    Month::from_name

    fn Month::from_name(name : String) -> Month?

    The month named by name: its full English name ("January") or its three-letter abbreviation ("Jan"), ignoring ASCII letter case, or None for anything else (including a prefix, an abbreviation of another length such as "Sept", surrounding whitespace, or non-ASCII text).

    Month::from_number

    fn Month::from_number(n : Int) -> Month?

    The month for a 1-based month-of-year number, or None if n is outside 1..=12.

    Month::hash

    fn Month::hash(self : Month) -> Int

    Month::hash_combine

    fn Month::hash_combine(Month, Hasher) -> Unit

    Month::name

    fn Month::name(self : Month) -> String

    The English name of the month.

    Month::not_equal

    fn Month::not_equal(x : Month, y : Month) -> Bool

    Month::num_days

    fn Month::num_days(self : Month, year : Int) -> Int

    The number of days in the month for the given (proleptic Gregorian) year, accounting for leap years in Feb. A month alone does not know the year, hence the argument; see NaiveDate::num_days_in_month for the month of a date.

    Month::number

    fn Month::number(self : Month) -> Int

    Month-of-year number counting from Jan = 1.

    Month::op_ge

    fn Month::op_ge(x : Month, y : Month) -> Bool

    Month::op_gt

    fn Month::op_gt(x : Month, y : Month) -> Bool

    Month::op_le

    fn Month::op_le(x : Month, y : Month) -> Bool

    Month::op_lt

    fn Month::op_lt(x : Month, y : Month) -> Bool

    Month::output

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

    Month::pred

    fn Month::pred(self : Month) -> Month

    The previous month, wrapping from Jan back to Dec.

    Month::succ

    fn Month::succ(self : Month) -> Month

    The next month, wrapping from Dec back to Jan.

    Month::to_repr

    Month::to_string

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

    NaiveDate

    pub struct NaiveDate {
    // private fields
    } derive(Compare, Eq, Hash,
    Debug
    )

    A proleptic Gregorian calendar date, without a time-of-day or time zone.

    Internally represented as a day count relative to the Unix epoch (1970-01-01 is day 0).
    impl Show for NaiveDate

    NaiveDate::abs_diff_days

    fn NaiveDate::abs_diff_days(self : NaiveDate, other : NaiveDate) -> Int64

    The number of days between this date and other, always non-negative regardless of which is earlier. A plain count: signed_duration_since gives the signed span as a TimeDelta, and this equals signed_duration_since(other).abs().num_days().

    NaiveDate::add_days

    fn NaiveDate::add_days(self : NaiveDate, days : Int) -> NaiveDate

    The date days days after this one (or before it, if days is negative).

    Aborts if the result falls outside NaiveDate's representable range; use checked_add_days to get None instead.

    NaiveDate::add_months

    fn NaiveDate::add_months(self : NaiveDate, months : Int) -> NaiveDate

    The date months months after this one (or before it, if months is negative). The day-of-month is clamped to the target month's length when it doesn't exist there (e.g. Jan 31 + 1 month becomes Feb 28 or Feb 29).

    Aborts if the result falls outside NaiveDate's representable range; use checked_add_months to get None instead.

    NaiveDate::add_signed

    fn NaiveDate::add_signed(self : NaiveDate, delta : TimeDelta) -> NaiveDate

    The date delta's whole days after this one. A sub-day remainder of delta is discarded (truncation toward zero), since a date carries no time-of-day.

    Aborts if the day count falls outside NaiveDate's representable range; use checked_add_signed to get None instead.

    NaiveDate::add_years

    fn NaiveDate::add_years(self : NaiveDate, years : Int) -> NaiveDate

    The date years years after this one (or before it, if years is negative), keeping the month and clamping the day of month to the target month's length when it doesn't exist there (February 29 becomes February 28 in a non-leap year). Equivalent to add_months(12 * years).

    Aborts if the result falls outside NaiveDate's representable range; use checked_add_years to get None instead.

    NaiveDate::and_hms

    fn NaiveDate::and_hms(self : NaiveDate, hour : Int, min : Int, sec : Int) -> NaiveDateTime?

    The datetime at hour:min:sec on this date, or None if any time component is out of range (see NaiveTime::from_hms).

    NaiveDate::and_hms_micro

    fn NaiveDate::and_hms_micro(self : NaiveDate, hour : Int, min : Int, sec : Int, micro : Int) -> NaiveDateTime?

    The datetime at hour:min:sec plus micro microseconds on this date, or None if any time component is out of range (see NaiveTime::from_hms_micro).

    NaiveDate::and_hms_milli

    fn NaiveDate::and_hms_milli(self : NaiveDate, hour : Int, min : Int, sec : Int, milli : Int) -> NaiveDateTime?

    The datetime at hour:min:sec plus milli milliseconds on this date, or None if any time component is out of range (see NaiveTime::from_hms_milli).

    NaiveDate::and_hms_nano

    fn NaiveDate::and_hms_nano(self : NaiveDate, hour : Int, min : Int, sec : Int, nano : Int) -> NaiveDateTime?

    The datetime at hour:min:sec plus nano nanoseconds on this date, or None if any time component is out of range (see NaiveTime::from_hms_nano).

    NaiveDate::and_time

    fn NaiveDate::and_time(self : NaiveDate, time : NaiveTime) -> NaiveDateTime

    The datetime at time on this date, the total member of the and_hms* family (which take components and return None for invalid ones) and the same value as NaiveDateTime::new(self, time).

    NaiveDate::checked_add_days

    fn NaiveDate::checked_add_days(self : NaiveDate, days : Int) -> NaiveDate?

    The date days days after this one (or before it, if days is negative), or None if the result falls outside NaiveDate's representable range.

    NaiveDate::checked_add_months

    fn NaiveDate::checked_add_months(self : NaiveDate, months : Int) -> NaiveDate?

    The date months months after this one (or before it, if months is negative), or None if the result falls outside NaiveDate's representable range. See add_months for the day-of-month clamping rule.

    NaiveDate::checked_add_signed

    fn NaiveDate::checked_add_signed(self : NaiveDate, delta : TimeDelta) -> NaiveDate?

    Like add_signed, but None if the day count falls outside NaiveDate's representable range.

    NaiveDate::checked_add_years

    fn NaiveDate::checked_add_years(self : NaiveDate, years : Int) -> NaiveDate?

    The date years years after this one, or None if the result falls outside NaiveDate's representable range. See add_years.

    NaiveDate::checked_pred

    fn NaiveDate::checked_pred(self : NaiveDate) -> NaiveDate?

    The previous calendar day, or None if this is the first representable date.

    NaiveDate::checked_sub_days

    fn NaiveDate::checked_sub_days(self : NaiveDate, days : Int) -> NaiveDate?

    The date days days before this one (or after it, if days is negative), or None if the result falls outside NaiveDate's representable range.

    NaiveDate::checked_sub_months

    fn NaiveDate::checked_sub_months(self : NaiveDate, months : Int) -> NaiveDate?

    The date months months before this one (or after it, if months is negative), or None if the result falls outside NaiveDate's representable range.

    NaiveDate::checked_sub_signed

    fn NaiveDate::checked_sub_signed(self : NaiveDate, delta : TimeDelta) -> NaiveDate?

    Like sub_signed, but None if the day count falls outside NaiveDate's representable range.

    NaiveDate::checked_sub_years

    fn NaiveDate::checked_sub_years(self : NaiveDate, years : Int) -> NaiveDate?

    The date years years before this one, or None if the result falls outside NaiveDate's representable range. See add_years.

    NaiveDate::checked_succ

    fn NaiveDate::checked_succ(self : NaiveDate) -> NaiveDate?

    The next calendar day, or None if this is the last representable date.

    NaiveDate::compare

    fn NaiveDate::compare(NaiveDate, NaiveDate) -> Int

    NaiveDate::day

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

    The day of the month.

    NaiveDate::day0

    fn NaiveDate::day0(self : NaiveDate) -> Int

    The day of the month, counting from 0 (0..=30).

    NaiveDate::default

    fn NaiveDate::default() -> NaiveDate

    NaiveDate::epoch_days

    fn NaiveDate::epoch_days(self : NaiveDate) -> Int

    The number of days since the Unix epoch (1970-01-01 is day 0; earlier dates are negative).

    NaiveDate::equal

    fn NaiveDate::equal(NaiveDate, NaiveDate) -> Bool

    NaiveDate::from_epoch_days

    fn NaiveDate::from_epoch_days(days : Int) -> NaiveDate?

    The date days days after the Unix epoch (1970-01-01 is day 0), or None if days falls outside NaiveDate's representable range.

    NaiveDate::from_isoywd

    fn NaiveDate::from_isoywd(year : Int, week : Int, weekday : Weekday) -> NaiveDate?

    Constructs the date for a given ISO 8601 week date (ISO year, 1-based week number, and weekday), or None if week does not exist in that ISO year, or the date falls outside NaiveDate's representable range. The resulting date's calendar year may differ from year (a week near a year boundary can belong to the adjoining calendar year).

    NaiveDate::from_num_days_from_ce

    fn NaiveDate::from_num_days_from_ce(days : Int) -> NaiveDate?

    The date whose num_days_from_ce() is days, or None if days falls outside NaiveDate's representable range.

    NaiveDate::from_weekday_of_month

    fn NaiveDate::from_weekday_of_month(year : Int, month : Int, weekday : Weekday, n : Int) -> NaiveDate?

    The n-th occurrence (1-indexed) of weekday within the given month, e.g. NaiveDate::from_weekday_of_month(2017, 3, Fri, 2) is the 2nd Friday of March 2017. None if n is not positive, year/month is invalid, or that occurrence doesn't exist in the month (e.g. a 5th Monday in a month that only has four).

    NaiveDate::from_ymd

    fn NaiveDate::from_ymd(year : Int, month : Int, day : Int) -> NaiveDate?

    Constructs the date for a given proleptic Gregorian (year, month, day), or None if month is outside 1..=12, day is outside the range of days in that month, or the date falls outside NaiveDate's representable range.

    NaiveDate::from_yo

    fn NaiveDate::from_yo(year : Int, ordinal : Int) -> NaiveDate?

    Constructs the date for a given year and 1-based day-of-year ordinal, or None if ordinal is outside 1..=365 (1..=366 in a leap year) or the date falls outside NaiveDate's representable range.

    NaiveDate::hash

    fn NaiveDate::hash(self : NaiveDate) -> Int

    NaiveDate::hash_combine

    fn NaiveDate::hash_combine(NaiveDate, Hasher) -> Unit

    NaiveDate::iso_week

    fn NaiveDate::iso_week(self : NaiveDate) -> IsoWeek

    The ISO 8601 week-numbering year and week this date falls in. Computed as the calendar year and day-of-year of the Thursday in this date's week, since the ISO week containing a year's first Thursday is always that year's week 1.

    NaiveDate::iter_days

    fn NaiveDate::iter_days(self : NaiveDate) -> NaiveDateDaysIterator

    A lazy, bounded, double-ended iterator over successive dates starting from this one, stepping by one day, up to and including a conservative practical upper bound (+275760-09-13, matching the well-known ECMAScript Date representable range). See NaiveDateDaysIterator.

    NaiveDate::iter_weeks

    fn NaiveDate::iter_weeks(self : NaiveDate) -> NaiveDateWeeksIterator

    A lazy, bounded, double-ended iterator over successive dates starting from this one, stepping by one week, aligned so its upper bound is the last date of the form self + 7k that doesn't exceed iter_days's own practical upper bound. See NaiveDateWeeksIterator.

    NaiveDate::leap_year

    fn NaiveDate::leap_year(self : NaiveDate) -> Bool

    Whether the date's calendar year is a leap year.

    NaiveDate::month

    fn NaiveDate::month(self : NaiveDate) -> Month

    The month of the year, as the typed Month; month().number() is the one-based number and month0() the zero-based one.

    NaiveDate::month0

    fn NaiveDate::month0(self : NaiveDate) -> Int

    The month of the year, counting from 0 (Jan is 0, Dec is 11).

    NaiveDate::not_equal

    fn NaiveDate::not_equal(x : NaiveDate, y : NaiveDate) -> Bool

    NaiveDate::num_days_from_ce

    fn NaiveDate::num_days_from_ce(self : NaiveDate) -> Int

    The number of days since the start of the Common Era, counting 0001-01-01 as day 1 (so 0000-12-31 is day 0).

    NaiveDate::num_days_in_month

    fn NaiveDate::num_days_in_month(self : NaiveDate) -> Int

    The number of days in this date's month, accounting for leap years; see Month::num_days for a month and a year given separately.

    NaiveDate::op_ge

    fn NaiveDate::op_ge(x : NaiveDate, y : NaiveDate) -> Bool

    NaiveDate::op_gt

    fn NaiveDate::op_gt(x : NaiveDate, y : NaiveDate) -> Bool

    NaiveDate::op_le

    fn NaiveDate::op_le(x : NaiveDate, y : NaiveDate) -> Bool

    NaiveDate::op_lt

    fn NaiveDate::op_lt(x : NaiveDate, y : NaiveDate) -> Bool

    NaiveDate::ordinal

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

    The 1-based day of the year.

    NaiveDate::ordinal0

    fn NaiveDate::ordinal0(self : NaiveDate) -> Int

    The day of the year, counting from 0 (0..=365).

    NaiveDate::output

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

    NaiveDate::pred

    fn NaiveDate::pred(self : NaiveDate) -> NaiveDate

    The previous calendar day.

    Aborts if the result falls outside NaiveDate's representable range; use checked_pred to get None instead.

    NaiveDate::quarter

    fn NaiveDate::quarter(self : NaiveDate) -> Int

    The calendar quarter, 1..=4.

    NaiveDate::signed_duration_since

    fn NaiveDate::signed_duration_since(self : NaiveDate, other : NaiveDate) -> TimeDelta

    The duration from other to this date, always a whole number of days. Total: NaiveDate's day range is far narrower than TimeDelta's.

    NaiveDate::sub_days

    fn NaiveDate::sub_days(self : NaiveDate, days : Int) -> NaiveDate

    The date days days before this one (or after it, if days is negative).

    Aborts if the result falls outside NaiveDate's representable range; use checked_sub_days to get None instead.

    NaiveDate::sub_months

    fn NaiveDate::sub_months(self : NaiveDate, months : Int) -> NaiveDate

    The date months months before this one (or after it, if months is negative). See add_months for the day-of-month clamping rule.

    Aborts if the result falls outside NaiveDate's representable range; use checked_sub_months to get None instead.

    NaiveDate::sub_signed

    fn NaiveDate::sub_signed(self : NaiveDate, delta : TimeDelta) -> NaiveDate

    The date delta's whole days before this one. A sub-day remainder of delta is discarded (truncation toward zero).

    Aborts if the day count falls outside NaiveDate's representable range; use checked_sub_signed to get None instead.

    NaiveDate::sub_years

    fn NaiveDate::sub_years(self : NaiveDate, years : Int) -> NaiveDate

    The date years years before this one (or after it, if years is negative). See add_years for the day-of-month clamping rule.

    Aborts if the result falls outside NaiveDate's representable range; use checked_sub_years to get None instead.

    NaiveDate::succ

    fn NaiveDate::succ(self : NaiveDate) -> NaiveDate

    The next calendar day.

    Aborts if the result falls outside NaiveDate's representable range; use checked_succ to get None instead.

    NaiveDate::to_string

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

    NaiveDate::week

    fn NaiveDate::week(self : NaiveDate, start : Weekday) -> NaiveWeek

    The calendar week containing this date, with weeks starting on start.

    NaiveDate::weekday

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

    The day of the week.

    NaiveDate::with_day

    fn NaiveDate::with_day(self : NaiveDate, day : Int) -> NaiveDate?

    The date with the day-of-month replaced by day, or None if day is outside the current month's length.

    NaiveDate::with_day0

    fn NaiveDate::with_day0(self : NaiveDate, day0 : Int) -> NaiveDate?

    Like with_day, but taking a 0-based day of the month.

    NaiveDate::with_month

    fn NaiveDate::with_month(self : NaiveDate, month : Int) -> NaiveDate?

    The date with the month replaced by month, or None if month is outside 1..=12 or the current day does not exist in that month.

    NaiveDate::with_month0

    fn NaiveDate::with_month0(self : NaiveDate, month0 : Int) -> NaiveDate?

    Like with_month, but taking a 0-based month (0..=11).

    NaiveDate::with_ordinal

    fn NaiveDate::with_ordinal(self : NaiveDate, ordinal : Int) -> NaiveDate?

    The date with the day-of-year replaced by ordinal, or None if ordinal is outside 1..=365 (1..=366 in a leap year).

    NaiveDate::with_ordinal0

    fn NaiveDate::with_ordinal0(self : NaiveDate, ordinal0 : Int) -> NaiveDate?

    Like with_ordinal, but taking a 0-based day of the year.

    NaiveDate::with_year

    fn NaiveDate::with_year(self : NaiveDate, year : Int) -> NaiveDate?

    The date with the year replaced by year, or None if the current month and day do not exist in year (e.g. moving February 29 into a year that is not a leap year).

    NaiveDate::year

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

    The proleptic Gregorian calendar year.

    NaiveDate::year_ce

    fn NaiveDate::year_ce(self : NaiveDate) -> YearCe

    The year split into a Common Era flag and a positive year number: year 1 and later are (true, year), and year 0 and earlier are (false, 1 - year), so year 0 is (false, 1) and year -1 is (false, 2).

    NaiveDate::years_since

    fn NaiveDate::years_since(self : NaiveDate, base : NaiveDate) -> Int?

    The number of full calendar years elapsed from base to self (e.g. someone born on base turns this many years old on self), or None if self is before base. A year only counts once self's month and day have both reached (or passed) base's.

    NaiveDate::ymd

    fn NaiveDate::ymd(self : NaiveDate) -> (Int, Month, Int)

    The year, month, and day of month together. The month is a Month, so pass month.number() to from_ymd to rebuild the date.

    NaiveDateDaysIterator

    pub struct NaiveDateDaysIterator {
    // private fields
    } derive(
    Debug
    )

    A lazy, bounded, double-ended iterator over successive dates, stepping by one day. See NaiveDate::iter_days.

    An iterator is a position that is consumed, the one stateful kind of value in this package: next and next_back advance it in place, iter does not advance it by itself but returns an Iter that shares its state, and the method that creates it (NaiveDate::iter_days) returns a fresh iterator on every call, leaving the date unchanged.

    NaiveDateDaysIterator::iter

    This iterator as a standard Iter, so it works in a for loop (for date in start.iter_days()) and with adapters such as map and take. The Iter shares this iterator's state: whatever it consumes from the front is consumed here too, and it stops before any dates already taken with next_back.

    NaiveDateDaysIterator::length

    The number of dates remaining to be yielded.

    NaiveDateDaysIterator::next

    The next date, advancing forward, or None once every date up to and including the upper bound has been yielded.

    NaiveDateDaysIterator::next_back

    The next date from the back, moving backward, or None once every date down to and including the current front has been yielded.

    NaiveDateTime

    pub struct NaiveDateTime {
    // private fields
    } derive(Compare, Eq, Hash,
    Debug
    )

    A date and time of day, without a time zone.

    NaiveDateTime::add_days

    fn NaiveDateTime::add_days(self : NaiveDateTime, days : Int) -> NaiveDateTime

    This datetime with its date advanced by days (or moved back, if days is negative), keeping the time of day unchanged.

    Aborts if the result falls outside NaiveDate's representable range; use checked_add_days to get None instead.

    NaiveDateTime::add_months

    fn NaiveDateTime::add_months(self : NaiveDateTime, months : Int) -> NaiveDateTime

    This datetime with its date advanced by months (or moved back, if months is negative), keeping the time of day unchanged. See NaiveDate::add_months for the day-of-month clamping rule.

    Aborts if the result falls outside NaiveDate's representable range; use checked_add_months to get None instead.

    NaiveDateTime::add_seconds

    fn NaiveDateTime::add_seconds(self : NaiveDateTime, seconds : Int64) -> NaiveDateTime

    This datetime shifted forward by seconds whole seconds (backward if negative). A convenience over add_signed with a TimeDelta built from the same seconds, e.g. to apply a UTC offset; a nonzero shift follows add_signed's leap-second rule, and a zero shift changes nothing.

    Aborts if the result falls outside NaiveDate's representable range; use checked_add_seconds to get None instead.

    NaiveDateTime::add_signed

    fn NaiveDateTime::add_signed(self : NaiveDateTime, delta : TimeDelta) -> NaiveDateTime

    This datetime advanced by the signed duration delta, propagating any day overflow from the time-of-day arithmetic into the date. See NaiveTime::overflowing_add_signed for the wrapping and leap-second rules.

    Aborts if the result falls outside NaiveDate's representable range; use checked_add_signed to get None instead.

    NaiveDateTime::add_years

    fn NaiveDateTime::add_years(self : NaiveDateTime, years : Int) -> NaiveDateTime

    This datetime with its date advanced by years (or moved back, if years is negative), keeping the time of day unchanged. See NaiveDate::add_years for the day-of-month clamping rule.

    Aborts if the result falls outside NaiveDate's representable range; use checked_add_years to get None instead.

    NaiveDateTime::checked_add_days

    fn NaiveDateTime::checked_add_days(self : NaiveDateTime, days : Int) -> NaiveDateTime?

    Like add_days, but None if the resulting date falls outside NaiveDate's representable range.

    NaiveDateTime::checked_add_months

    fn NaiveDateTime::checked_add_months(self : NaiveDateTime, months : Int) -> NaiveDateTime?

    Like add_months, but None if the resulting date falls outside NaiveDate's representable range.

    NaiveDateTime::checked_add_seconds

    fn NaiveDateTime::checked_add_seconds(self : NaiveDateTime, seconds : Int64) -> NaiveDateTime?

    Like add_seconds, but None if the result falls outside NaiveDate's representable range.

    NaiveDateTime::checked_add_signed

    fn NaiveDateTime::checked_add_signed(self : NaiveDateTime, delta : TimeDelta) -> NaiveDateTime?

    This datetime advanced by the signed duration delta, or None if the resulting date falls outside NaiveDate's representable range. See add_signed.

    NaiveDateTime::checked_add_years

    fn NaiveDateTime::checked_add_years(self : NaiveDateTime, years : Int) -> NaiveDateTime?

    Like add_years, but None if the resulting date falls outside NaiveDate's representable range.

    NaiveDateTime::checked_sub_days

    fn NaiveDateTime::checked_sub_days(self : NaiveDateTime, days : Int) -> NaiveDateTime?

    Like sub_days, but None if the resulting date falls outside NaiveDate's representable range.

    NaiveDateTime::checked_sub_months

    fn NaiveDateTime::checked_sub_months(self : NaiveDateTime, months : Int) -> NaiveDateTime?

    Like sub_months, but None if the resulting date falls outside NaiveDate's representable range.

    NaiveDateTime::checked_sub_seconds

    fn NaiveDateTime::checked_sub_seconds(self : NaiveDateTime, seconds : Int64) -> NaiveDateTime?

    Like sub_seconds, but None if the result falls outside NaiveDate's representable range.

    NaiveDateTime::checked_sub_signed

    fn NaiveDateTime::checked_sub_signed(self : NaiveDateTime, delta : TimeDelta) -> NaiveDateTime?

    This datetime moved back by the signed duration delta, or None if the resulting date falls outside NaiveDate's representable range.

    NaiveDateTime::checked_sub_years

    fn NaiveDateTime::checked_sub_years(self : NaiveDateTime, years : Int) -> NaiveDateTime?

    Like sub_years, but None if the resulting date falls outside NaiveDate's representable range.

    NaiveDateTime::compare

    NaiveDateTime::date

    The date component.

    NaiveDateTime::day

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

    The day of the month, 1..=31.

    NaiveDateTime::day0

    fn NaiveDateTime::day0(self : NaiveDateTime) -> Int

    The day of the month, counting from 0. See NaiveDate::day0.

    NaiveDateTime::default

    fn NaiveDateTime::default() -> NaiveDateTime

    NaiveDateTime::equal

    NaiveDateTime::from_timestamp

    fn NaiveDateTime::from_timestamp(secs : Int64, nanos : Int) -> NaiveDateTime?

    Constructs the datetime for a Unix timestamp given as whole seconds plus a nanosecond component, or None if nanos is outside 0..=1_999_999_999 (a value at or above 1_000_000_000 represents a leap second; see NaiveTime::nanosecond).

    NaiveDateTime::from_timestamp_micros

    fn NaiveDateTime::from_timestamp_micros(micros : Int64) -> NaiveDateTime?

    Constructs the datetime for a Unix timestamp given in whole microseconds.

    NaiveDateTime::from_timestamp_millis

    fn NaiveDateTime::from_timestamp_millis(millis : Int64) -> NaiveDateTime?

    Constructs the datetime for a Unix timestamp given in whole milliseconds.

    NaiveDateTime::from_timestamp_nanos

    fn NaiveDateTime::from_timestamp_nanos(nanos : Int64) -> NaiveDateTime?

    Constructs the datetime for a Unix timestamp given in whole nanoseconds.

    NaiveDateTime::from_ymd_hms

    fn NaiveDateTime::from_ymd_hms(year : Int, month : Int, day : Int, hour : Int, min : Int, sec : Int) -> NaiveDateTime?

    The datetime at the given year, month, day, hour, minute and second, or None if any component is out of range (see NaiveDate::from_ymd and NaiveTime::from_hms).

    NaiveDateTime::hash

    fn NaiveDateTime::hash(self : NaiveDateTime) -> Int

    NaiveDateTime::hash_combine

    fn NaiveDateTime::hash_combine(NaiveDateTime, Hasher) -> Unit

    NaiveDateTime::hms

    fn NaiveDateTime::hms(self : NaiveDateTime) -> (Int, Int, Int)

    The hour, minute, and second together.

    NaiveDateTime::hour

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

    The hour, 0..=23.

    NaiveDateTime::hour12

    The hour on a 12-hour clock as a PM flag and an hour in 1..=12. See NaiveTime::hour12.

    NaiveDateTime::iso_week

    fn NaiveDateTime::iso_week(self : NaiveDateTime) -> IsoWeek

    The ISO 8601 week date's year and week number.

    NaiveDateTime::leap_year

    fn NaiveDateTime::leap_year(self : NaiveDateTime) -> Bool

    Whether the calendar year is a leap year.

    NaiveDateTime::minute

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

    The minute, 0..=59.

    NaiveDateTime::month

    fn NaiveDateTime::month(self : NaiveDateTime) -> Month

    The calendar month.

    NaiveDateTime::month0

    fn NaiveDateTime::month0(self : NaiveDateTime) -> Int

    The month of the year, counting from 0. See NaiveDate::month0.

    NaiveDateTime::nanosecond

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

    The nanosecond within the second, 0..=1_999_999_999 (a value at or above 1_000_000_000 represents a leap second).

    NaiveDateTime::new

    fn NaiveDateTime::new(date : NaiveDate, time : NaiveTime) -> NaiveDateTime

    Composes a NaiveDate and a NaiveTime into a NaiveDateTime. This is the constructor from two parts; NaiveDate::and_time reads the same from the date's side.

    NaiveDateTime::not_equal

    fn NaiveDateTime::not_equal(x : NaiveDateTime, y : NaiveDateTime) -> Bool

    NaiveDateTime::num_days_from_ce

    fn NaiveDateTime::num_days_from_ce(self : NaiveDateTime) -> Int

    The number of days since the start of the Common Era, counting 0001-01-01 as day 1. See NaiveDate::num_days_from_ce.

    NaiveDateTime::num_days_in_month

    fn NaiveDateTime::num_days_in_month(self : NaiveDateTime) -> Int

    The number of days in this datetime's month. See NaiveDate::num_days_in_month.

    NaiveDateTime::num_seconds_from_midnight

    fn NaiveDateTime::num_seconds_from_midnight(self : NaiveDateTime) -> Int

    The number of seconds since midnight. See NaiveTime::num_seconds_from_midnight.

    NaiveDateTime::op_ge

    fn NaiveDateTime::op_ge(x : NaiveDateTime, y : NaiveDateTime) -> Bool

    NaiveDateTime::op_gt

    fn NaiveDateTime::op_gt(x : NaiveDateTime, y : NaiveDateTime) -> Bool

    NaiveDateTime::op_le

    fn NaiveDateTime::op_le(x : NaiveDateTime, y : NaiveDateTime) -> Bool

    NaiveDateTime::op_lt

    fn NaiveDateTime::op_lt(x : NaiveDateTime, y : NaiveDateTime) -> Bool

    NaiveDateTime::ordinal

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

    The day of the year, 1..=366.

    NaiveDateTime::ordinal0

    fn NaiveDateTime::ordinal0(self : NaiveDateTime) -> Int

    The day of the year, counting from 0. See NaiveDate::ordinal0.

    NaiveDateTime::output

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

    NaiveDateTime::quarter

    fn NaiveDateTime::quarter(self : NaiveDateTime) -> Int

    The quarter of the year, 1..=4. See NaiveDate::quarter.

    NaiveDateTime::round

    fn NaiveDateTime::round(self : NaiveDateTime, granularity : TimeDelta) -> Result[NaiveDateTime, RoundingError]

    This datetime rounded to the nearest multiple of granularity since the Unix epoch, ties breaking away from the epoch. See TimeDelta::round for the conditions under which granularity is rejected; also fails with OutOfRange if rounding away from the epoch would leave NaiveDate's representable range.

    NaiveDateTime::round_subsecs

    fn NaiveDateTime::round_subsecs(self : NaiveDateTime, digits : Int) -> Result[NaiveDateTime, RoundingError]

    This datetime rounded to digits fractional-second digits (0..=9), with the tie-breaking and range behavior of round: OutOfRange if rounding away from the epoch would leave NaiveDate's representable range. A datetime with no digits beyond digits is returned unchanged, leap second included; otherwise a leap second folds into the following second.

    Aborts if digits is outside 0..=9.

    NaiveDateTime::round_up

    fn NaiveDateTime::round_up(self : NaiveDateTime, granularity : TimeDelta) -> Result[NaiveDateTime, RoundingError]

    This datetime rounded up (toward positive infinity) to the nearest multiple of granularity since the Unix epoch: unchanged if already a multiple, otherwise the next one after it. See TimeDelta::round_up. Fails if granularity is rejected, or with OutOfRange if the result falls outside NaiveDate's representable range.

    NaiveDateTime::second

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

    The second, 0..=59 (never 60; see nanosecond for leap seconds).

    NaiveDateTime::signed_duration_since

    fn NaiveDateTime::signed_duration_since(self : NaiveDateTime, other : NaiveDateTime) -> TimeDelta

    The signed duration from other to self (positive if self is later). Always succeeds: the difference between any two dates in NaiveDate's representable range comfortably fits TimeDelta's much wider representable range.

    NaiveDateTime::sub_days

    fn NaiveDateTime::sub_days(self : NaiveDateTime, days : Int) -> NaiveDateTime

    This datetime with its date moved back by days. See add_days.

    Aborts if the result falls outside NaiveDate's representable range; use checked_sub_days to get None instead.

    NaiveDateTime::sub_months

    fn NaiveDateTime::sub_months(self : NaiveDateTime, months : Int) -> NaiveDateTime

    This datetime with its date moved back by months. See add_months.

    Aborts if the result falls outside NaiveDate's representable range; use checked_sub_months to get None instead.

    NaiveDateTime::sub_seconds

    fn NaiveDateTime::sub_seconds(self : NaiveDateTime, seconds : Int64) -> NaiveDateTime

    This datetime shifted backward by seconds whole seconds (forward if negative). See add_seconds.

    Aborts if the result falls outside NaiveDate's representable range; use checked_sub_seconds to get None instead.

    NaiveDateTime::sub_signed

    fn NaiveDateTime::sub_signed(self : NaiveDateTime, delta : TimeDelta) -> NaiveDateTime

    This datetime moved back by the signed duration delta. See add_signed.

    Aborts if the result falls outside NaiveDate's representable range; use checked_sub_signed to get None instead.

    NaiveDateTime::sub_years

    fn NaiveDateTime::sub_years(self : NaiveDateTime, years : Int) -> NaiveDateTime

    This datetime with its date moved back by years. See add_years.

    Aborts if the result falls outside NaiveDate's representable range; use checked_sub_years to get None instead.

    NaiveDateTime::time

    The time-of-day component.

    NaiveDateTime::timestamp

    fn NaiveDateTime::timestamp(self : NaiveDateTime) -> Int64

    The Unix timestamp, in whole seconds, truncated toward negative infinity (i.e. the seconds component of from_timestamp's inverse). Does not account for a leap second's extra elapsed second, matching NaiveTime::num_seconds_from_midnight.

    NaiveDateTime::timestamp_micros

    fn NaiveDateTime::timestamp_micros(self : NaiveDateTime) -> Int64?

    The Unix timestamp in whole microseconds, or None if it does not fit in Int64 (possible for a date far from the epoch).

    NaiveDateTime::timestamp_millis

    fn NaiveDateTime::timestamp_millis(self : NaiveDateTime) -> Int64

    The Unix timestamp in whole milliseconds. Always succeeds: unlike timestamp_micros/timestamp_nanos, this stays within Int64 even at the extremes of NaiveDate's representable range.

    NaiveDateTime::timestamp_nanos

    fn NaiveDateTime::timestamp_nanos(self : NaiveDateTime) -> Int64?

    The Unix timestamp in whole nanoseconds, or None if it does not fit in Int64 (possible for a date far from the epoch).

    NaiveDateTime::timestamp_subsec_micros

    fn NaiveDateTime::timestamp_subsec_micros(self : NaiveDateTime) -> Int

    The nanosecond component of this instant, expressed in whole microseconds.

    NaiveDateTime::timestamp_subsec_millis

    fn NaiveDateTime::timestamp_subsec_millis(self : NaiveDateTime) -> Int

    The nanosecond component of this instant, expressed in whole milliseconds.

    NaiveDateTime::timestamp_subsec_nanos

    fn NaiveDateTime::timestamp_subsec_nanos(self : NaiveDateTime) -> Int

    The nanosecond component of this instant, 0..=1_999_999_999 (see NaiveTime::nanosecond for the leap-second convention).

    NaiveDateTime::to_string

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

    NaiveDateTime::truncate

    fn NaiveDateTime::truncate(self : NaiveDateTime, granularity : TimeDelta) -> Result[NaiveDateTime, RoundingError]

    This datetime truncated toward the Unix epoch to the nearest multiple of granularity. See TimeDelta::truncate for the conditions under which granularity is rejected.

    NaiveDateTime::truncate_subsecs

    fn NaiveDateTime::truncate_subsecs(self : NaiveDateTime, digits : Int) -> NaiveDateTime

    This datetime truncated to digits fractional-second digits (0..=9), toward the Unix epoch like truncate, so a datetime before the epoch moves forward in time. Always succeeds. A datetime with no digits beyond digits is returned unchanged, leap second included. Otherwise, like truncate and NaiveTime::truncate_subsecs, a leap second is treated as its elapsed instant and folds into the following second.

    Aborts if digits is outside 0..=9.

    NaiveDateTime::unix_epoch

    fn NaiveDateTime::unix_epoch() -> NaiveDateTime

    The Unix epoch instant, 1970-01-01T00:00:00: timestamp zero, and the reference point round, round_up and truncate measure a granularity against. Default::default() returns it.

    NaiveDateTime::weekday

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

    The day of the week.

    NaiveDateTime::with_date

    fn NaiveDateTime::with_date(self : NaiveDateTime, date : NaiveDate) -> NaiveDateTime

    This datetime with its date replaced by date, keeping the time of day.

    NaiveDateTime::with_day

    fn NaiveDateTime::with_day(self : NaiveDateTime, day : Int) -> NaiveDateTime?

    This datetime with its day replaced, or None if the result is not a valid date. The time of day is unchanged. See NaiveDate::with_day.

    NaiveDateTime::with_day0

    fn NaiveDateTime::with_day0(self : NaiveDateTime, day0 : Int) -> NaiveDateTime?

    Like with_day, but taking a 0-based day of the month. The time of day is unchanged.

    NaiveDateTime::with_hour

    fn NaiveDateTime::with_hour(self : NaiveDateTime, hour : Int) -> NaiveDateTime?

    This datetime with its hour replaced, or None if it is out of range. The date and every other time field (including a leap-second nanosecond) are unchanged. See NaiveTime::with_hour.

    NaiveDateTime::with_minute

    fn NaiveDateTime::with_minute(self : NaiveDateTime, minute : Int) -> NaiveDateTime?

    This datetime with its minute replaced, or None if it is out of range. The date and every other time field (including a leap-second nanosecond) are unchanged. See NaiveTime::with_minute.

    NaiveDateTime::with_month

    fn NaiveDateTime::with_month(self : NaiveDateTime, month : Int) -> NaiveDateTime?

    This datetime with its month replaced, or None if the result is not a valid date. The time of day is unchanged. See NaiveDate::with_month.

    NaiveDateTime::with_month0

    fn NaiveDateTime::with_month0(self : NaiveDateTime, month0 : Int) -> NaiveDateTime?

    Like with_month, but taking a 0-based month. The time of day is unchanged.

    NaiveDateTime::with_nanosecond

    fn NaiveDateTime::with_nanosecond(self : NaiveDateTime, nanosecond : Int) -> NaiveDateTime?

    This datetime with its nanosecond replaced, or None if it is out of range. The date and every other time field (including a leap-second nanosecond) are unchanged. See NaiveTime::with_nanosecond.

    NaiveDateTime::with_ordinal

    fn NaiveDateTime::with_ordinal(self : NaiveDateTime, ordinal : Int) -> NaiveDateTime?

    This datetime with its day of year replaced, or None if the result is not a valid date. The time of day is unchanged. See NaiveDate::with_ordinal.

    NaiveDateTime::with_ordinal0

    fn NaiveDateTime::with_ordinal0(self : NaiveDateTime, ordinal0 : Int) -> NaiveDateTime?

    Like with_ordinal, but taking a 0-based day of the year. The time of day is unchanged.

    NaiveDateTime::with_second

    fn NaiveDateTime::with_second(self : NaiveDateTime, second : Int) -> NaiveDateTime?

    This datetime with its second replaced, or None if it is out of range. The date and every other time field (including a leap-second nanosecond) are unchanged. See NaiveTime::with_second.

    NaiveDateTime::with_time

    fn NaiveDateTime::with_time(self : NaiveDateTime, time : NaiveTime) -> NaiveDateTime

    This datetime with its time of day replaced by time, keeping the date.

    NaiveDateTime::with_year

    fn NaiveDateTime::with_year(self : NaiveDateTime, year : Int) -> NaiveDateTime?

    This datetime with its year replaced, or None if the result is not a valid date. The time of day is unchanged. See NaiveDate::with_year.

    NaiveDateTime::year

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

    The calendar year.

    NaiveDateTime::year_ce

    fn NaiveDateTime::year_ce(self : NaiveDateTime) -> YearCe

    The year as a Common Era flag and a positive year number. See NaiveDate::year_ce.

    NaiveDateTime::years_since

    fn NaiveDateTime::years_since(self : NaiveDateTime, base : NaiveDateTime) -> Int?

    The number of full calendar years elapsed from base to self, or None if self is before base, comparing the dates and ignoring the time of day. See NaiveDate::years_since.

    NaiveDateTime::ymd

    fn NaiveDateTime::ymd(self : NaiveDateTime) -> (Int, Month, Int)

    The year, month, and day of month together.

    NaiveDateWeeksIterator

    pub struct NaiveDateWeeksIterator {
    // private fields
    } derive(
    Debug
    )

    A lazy, bounded, double-ended iterator over successive dates, stepping by one week. See NaiveDate::iter_weeks.

    An iterator is a position that is consumed, the one stateful kind of value in this package: next and next_back advance it in place, iter does not advance it by itself but returns an Iter that shares its state, and the method that creates it (NaiveDate::iter_weeks) returns a fresh iterator on every call, leaving the date unchanged.

    NaiveDateWeeksIterator::iter

    This iterator as a standard Iter, so it works in a for loop (for date in start.iter_weeks()) and with adapters such as map and take. The Iter shares this iterator's state, as for NaiveDateDaysIterator::iter.

    NaiveDateWeeksIterator::length

    The number of weekly steps remaining to be yielded.

    NaiveDateWeeksIterator::next

    The next date, advancing forward by a week, or None once every weekly step up to and including the upper bound has been yielded.

    NaiveDateWeeksIterator::next_back

    The next date from the back, moving backward by a week, or None once every weekly step down to and including the current front has been yielded.

    NaiveTime

    pub struct NaiveTime {
    // private fields
    } derive(Compare, Eq, Hash,
    Debug
    )

    A time of day, without a date or time zone.

    Internally represented as whole seconds since midnight (0..=86399) plus a nanosecond component. The nanosecond component is normally 0..=999_999_999, but may reach 1_999_999_999 to represent a leap second at second() == 59 (see nanosecond).
    impl Show for NaiveTime

    NaiveTime::compare

    fn NaiveTime::compare(NaiveTime, NaiveTime) -> Int

    NaiveTime::default

    fn NaiveTime::default() -> NaiveTime

    NaiveTime::equal

    fn NaiveTime::equal(NaiveTime, NaiveTime) -> Bool

    NaiveTime::from_hms

    fn NaiveTime::from_hms(hour : Int, min : Int, sec : Int) -> NaiveTime?

    Constructs the time for a given hour/minute/second, or None if any component is outside its valid range. See from_hms_nano for the exact ranges.

    NaiveTime::from_hms_micro

    fn NaiveTime::from_hms_micro(hour : Int, min : Int, sec : Int, micro : Int) -> NaiveTime?

    Constructs the time for a given hour/minute/second plus a microsecond component, or None if any component is outside its valid range (micro outside 0..=1_999_999; see from_hms_nano).

    NaiveTime::from_hms_milli

    fn NaiveTime::from_hms_milli(hour : Int, min : Int, sec : Int, milli : Int) -> NaiveTime?

    Constructs the time for a given hour/minute/second plus a millisecond component, or None if any component is outside its valid range (milli outside 0..=1999; see from_hms_nano).

    NaiveTime::from_hms_nano

    fn NaiveTime::from_hms_nano(hour : Int, min : Int, sec : Int, nano : Int) -> NaiveTime?

    Constructs the time for a given hour/minute/second/nanosecond, or None if hour is outside 0..=23, minute or second are outside 0..=59, or nanosecond is outside 0..=1_999_999_999. A nanosecond of 1_000_000_000 or above represents a leap second (see nanosecond).

    NaiveTime::from_num_seconds_from_midnight

    fn NaiveTime::from_num_seconds_from_midnight(secs : Int, nano : Int) -> NaiveTime?

    Constructs the time for a given count of seconds since midnight plus a nanosecond component, or None if secs is outside 0..=86399 or nano is outside 0..=1_999_999_999.

    NaiveTime::hash

    fn NaiveTime::hash(self : NaiveTime) -> Int

    NaiveTime::hash_combine

    fn NaiveTime::hash_combine(NaiveTime, Hasher) -> Unit

    NaiveTime::hms

    fn NaiveTime::hms(self : NaiveTime) -> (Int, Int, Int)

    The hour, minute, and second together, as hour, minute, and second report them.

    NaiveTime::hour

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

    The hour of the day, 0..=23.

    NaiveTime::hour12

    fn NaiveTime::hour12(self : NaiveTime) -> ClockHour12

    The hour of the day on a 12-hour clock, paired with whether it is PM. Midnight and noon both report hour 12 ((false, 12) and (true, 12) respectively).

    NaiveTime::midnight

    fn NaiveTime::midnight() -> NaiveTime

    The start of the day, 00:00:00 with no fractional part: the earliest time of day. Default::default() returns it.

    NaiveTime::minute

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

    The minute of the hour, 0..=59.

    NaiveTime::nanosecond

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

    The nanosecond component, normally 0..=999_999_999. A value of 1_000_000_000 or above indicates this time represents a leap second (displayed as second() + 1, i.e. :60), with the leap second's own fractional part equal to nanosecond() - 1_000_000_000.

    NaiveTime::not_equal

    fn NaiveTime::not_equal(x : NaiveTime, y : NaiveTime) -> Bool

    NaiveTime::num_seconds_from_midnight

    fn NaiveTime::num_seconds_from_midnight(self : NaiveTime) -> Int

    The count of seconds since midnight, 0..=86399. Does not account for a leap second's extra elapsed second; use nanosecond for that.

    NaiveTime::op_ge

    fn NaiveTime::op_ge(x : NaiveTime, y : NaiveTime) -> Bool

    NaiveTime::op_gt

    fn NaiveTime::op_gt(x : NaiveTime, y : NaiveTime) -> Bool

    NaiveTime::op_le

    fn NaiveTime::op_le(x : NaiveTime, y : NaiveTime) -> Bool

    NaiveTime::op_lt

    fn NaiveTime::op_lt(x : NaiveTime, y : NaiveTime) -> Bool

    NaiveTime::output

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

    NaiveTime::overflowing_add_signed

    fn NaiveTime::overflowing_add_signed(self : NaiveTime, delta : TimeDelta) -> (NaiveTime, Int64)

    This time advanced by the signed duration delta, wrapping across midnight. Returns the wrapped time together with the number of whole days the addition crossed (negative if delta is negative enough to cross backward).

    A zero delta returns this time unchanged, exactly preserving a leap second. Any other delta resolves the arithmetic assuming no day has a leap second, since NaiveTime carries no calendar context to know whether a nearby day actually has one; a leap second's extra elapsed second is treated as consumed once time moves away from it in either direction.

    NaiveTime::overflowing_sub_signed

    fn NaiveTime::overflowing_sub_signed(self : NaiveTime, delta : TimeDelta) -> (NaiveTime, Int64)

    This time moved back by the signed duration delta. See overflowing_add_signed for the wrapping and leap-second rules.

    NaiveTime::round_subsecs

    fn NaiveTime::round_subsecs(self : NaiveTime, digits : Int) -> NaiveTime

    This time rounded to the nearest of digits fractional-second digits (0..=9), a tie rounding up. A carry moves into the next second, minute, or hour and wraps from the end of the day to midnight; the day carry is discarded (use NaiveDateTime::round_subsecs to move the date forward). A time with no digits beyond digits is returned unchanged, leap second included (so 9 is always the identity). Otherwise a leap second is treated as its elapsed instant and folded into the following second, so the result is not a leap second.

    Aborts if digits is outside 0..=9.

    NaiveTime::second

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

    The second of the minute, 0..=59. Never reports 60 for a leap second; use nanosecond to detect one.

    NaiveTime::signed_duration_since

    fn NaiveTime::signed_duration_since(self : NaiveTime, other : NaiveTime) -> TimeDelta

    The signed duration from other to self, treating a leap second as coinciding with the prior non-leap second: its extra elapsed second is only counted once time moves away from it, in whichever direction.

    NaiveTime::to_string

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

    NaiveTime::truncate_subsecs

    fn NaiveTime::truncate_subsecs(self : NaiveTime, digits : Int) -> NaiveTime

    This time truncated to digits fractional-second digits (0..=9). A time with no digits beyond digits is returned unchanged, leap second included (so 9 is always the identity). Otherwise a leap second is treated as its elapsed instant and folded into the following second, so the result is not a leap second.

    Aborts if digits is outside 0..=9.

    NaiveTime::with_hour

    fn NaiveTime::with_hour(self : NaiveTime, hour : Int) -> NaiveTime?

    Same minute, second, and nanosecond, with the hour changed to hour, or None if hour is outside 0..=23.

    NaiveTime::with_minute

    fn NaiveTime::with_minute(self : NaiveTime, min : Int) -> NaiveTime?

    Same hour, second, and nanosecond, with the minute changed to min, or None if min is outside 0..=59.

    NaiveTime::with_nanosecond

    fn NaiveTime::with_nanosecond(self : NaiveTime, nano : Int) -> NaiveTime?

    Same hour, minute, and second, with the nanosecond component changed to nano, or None if nano is outside 0..=1_999_999_999. See nanosecond for how a value >= 1_000_000_000 represents a leap second.

    NaiveTime::with_second

    fn NaiveTime::with_second(self : NaiveTime, sec : Int) -> NaiveTime?

    Same hour, minute, and nanosecond, with the second changed to sec, or None if sec is outside 0..=59. As with second, this never represents a leap second itself; use with_nanosecond for that.

    NaiveTime::wrapping_add_signed

    fn NaiveTime::wrapping_add_signed(self : NaiveTime, delta : TimeDelta) -> NaiveTime

    This time advanced by the signed duration delta, wrapping at midnight and discarding the number of days crossed (use overflowing_add_signed to get it). See overflowing_add_signed for the leap-second rules.

    There is no aborting add_signed or checked_add_signed for a time of day: it cannot leave its range, so the vocabulary is that of integer arithmetic, wrapping_* and overflowing_*.

    NaiveTime::wrapping_sub_signed

    fn NaiveTime::wrapping_sub_signed(self : NaiveTime, delta : TimeDelta) -> NaiveTime

    This time moved back by the signed duration delta, wrapping at midnight and discarding the number of days crossed. See wrapping_add_signed.

    NaiveWeek

    pub struct NaiveWeek {
    // private fields
    } derive(
    Debug
    )

    The week containing a NaiveDate, under a configurable first day of the week (see NaiveDate::week). Distinct from IsoWeek, which is always Monday-based and tied to the ISO 8601 week-numbering year.

    Two NaiveWeeks are equal (and compare) by the calendar week they denote, i.e. by first_day() alone — the anchor date and start weekday used to construct them don't affect equality.
    impl Eq for NaiveWeek
    impl Hash for NaiveWeek

    NaiveWeek::compare

    fn NaiveWeek::compare(self : NaiveWeek, other : NaiveWeek) -> Int

    NaiveWeek::days

    fn NaiveWeek::days(self : NaiveWeek) -> Array[NaiveDate]

    All seven days of the week, from first_day() to last_day().

    NaiveWeek::equal

    fn NaiveWeek::equal(self : NaiveWeek, other : NaiveWeek) -> Bool

    NaiveWeek::first_day

    fn NaiveWeek::first_day(self : NaiveWeek) -> NaiveDate

    The first day of the week (the start weekday, on or before the date this week was constructed from).

    NaiveWeek::hash

    fn NaiveWeek::hash(self : NaiveWeek) -> Int

    NaiveWeek::hash_combine

    fn NaiveWeek::hash_combine(self : NaiveWeek, hasher : Hasher) -> Unit

    NaiveWeek::last_day

    fn NaiveWeek::last_day(self : NaiveWeek) -> NaiveDate

    The last day of the week, six days after first_day().

    NaiveWeek::not_equal

    fn NaiveWeek::not_equal(x : NaiveWeek, y : NaiveWeek) -> Bool

    NaiveWeek::op_ge

    fn NaiveWeek::op_ge(x : NaiveWeek, y : NaiveWeek) -> Bool

    NaiveWeek::op_gt

    fn NaiveWeek::op_gt(x : NaiveWeek, y : NaiveWeek) -> Bool

    NaiveWeek::op_le

    fn NaiveWeek::op_le(x : NaiveWeek, y : NaiveWeek) -> Bool

    NaiveWeek::op_lt

    fn NaiveWeek::op_lt(x : NaiveWeek, y : NaiveWeek) -> Bool

    RoundingError

    pub(all) enum RoundingError {
    InvalidGranularity
    MixedGranularity
    OutOfRange
    } derive(Eq,
    Debug
    )

    The reason a round, round_up or truncate call could not produce a result.

    RoundingError::equal

    RoundingError::not_equal

    fn RoundingError::not_equal(x : RoundingError, y : RoundingError) -> Bool

    RoundingError::output

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

    RoundingError::to_string

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

    TimeDelta

    pub struct TimeDelta {
    // private fields
    } derive(Compare, Eq, Hash,
    Debug
    )

    A signed duration, precise to the nanosecond.

    Internally represented as whole seconds plus a non-negative nanosecond remainder (0..=999_999_999); the sign of the duration is carried entirely by the seconds component.
    impl Add for TimeDelta
    impl Neg for TimeDelta
    impl Show for TimeDelta
    impl Sub for TimeDelta

    TimeDelta::abs

    fn TimeDelta::abs(self : TimeDelta) -> TimeDelta

    The absolute value of this duration.

    TimeDelta::add

    fn TimeDelta::add(self : TimeDelta, other : TimeDelta) -> TimeDelta

    The sum of two durations.

    Aborts if it overflows the representable range; use checked_add to get None instead.

    TimeDelta::as_hours_double

    fn TimeDelta::as_hours_double(self : TimeDelta) -> Double

    This duration's total length in fractional hours, as a 64-bit float. Loses precision for a very large duration; never fails.

    TimeDelta::as_minutes_double

    fn TimeDelta::as_minutes_double(self : TimeDelta) -> Double

    This duration's total length in fractional minutes, as a 64-bit float. Loses precision for a very large duration; never fails.

    TimeDelta::as_seconds_double

    fn TimeDelta::as_seconds_double(self : TimeDelta) -> Double

    This duration's total length in fractional seconds, as a 64-bit float. Loses precision for a very large duration; never fails.

    TimeDelta::checked_add

    fn TimeDelta::checked_add(self : TimeDelta, other : TimeDelta) -> TimeDelta?

    The sum of two durations, or None if it overflows the representable range.

    The addition of the seconds components alone can never overflow Int64 (both operands are already bounded well within Int64's range by the representable-range check every TimeDelta satisfies), so no separate overflow check is needed here beyond the one from_secs_nanos already performs.

    TimeDelta::checked_div

    fn TimeDelta::checked_div(self : TimeDelta, scalar : Int) -> TimeDelta?

    This duration divided by the integer scalar, truncated toward zero, or None if scalar is zero.

    TimeDelta::checked_mul

    fn TimeDelta::checked_mul(self : TimeDelta, scalar : Int) -> TimeDelta?

    This duration multiplied by the integer scalar, or None if it overflows the representable range.

    Only the seconds component's multiplication needs a checked (Int64-overflowing) guard: nanoseconds is always below one second, so nanoseconds * scalar stays well within Int64 for any Int scalar.

    TimeDelta::checked_sub

    fn TimeDelta::checked_sub(self : TimeDelta, other : TimeDelta) -> TimeDelta?

    The difference of two durations, or None if it overflows the representable range.

    TimeDelta::checked_sum

    fn TimeDelta::checked_sum(deltas : Array[TimeDelta]) -> TimeDelta?

    The total of deltas, or None if the true total falls outside the representable range; an empty array totals zero(). Unlike folding with checked_add, the result does not depend on the order of deltas: a partial sum that would leave the range does not make the whole sum None, as long as the true total is representable. (Seconds are accumulated as high * 2^31 + low, so no partial sum can overflow Int64 whatever the order or length; scaled + total_low cannot overflow either, since scaled is a multiple of 2^31 and total_low is below it.)

    TimeDelta::compare

    fn TimeDelta::compare(TimeDelta, TimeDelta) -> Int

    TimeDelta::days

    fn TimeDelta::days(n : Int64) -> TimeDelta?

    The duration of the given number of whole days, or None if it does not fit in the representable range.

    TimeDelta::default

    fn TimeDelta::default() -> TimeDelta

    TimeDelta::div

    fn TimeDelta::div(self : TimeDelta, scalar : Int) -> TimeDelta

    This duration divided by the integer scalar, truncated toward zero.

    Aborts if scalar is zero; use checked_div to get None instead.

    TimeDelta::equal

    fn TimeDelta::equal(TimeDelta, TimeDelta) -> Bool

    TimeDelta::from_seconds_double

    fn TimeDelta::from_seconds_double(seconds : Double) -> TimeDelta?

    The duration of seconds fractional seconds, rounded to the nearest nanosecond with an exact half-nanosecond tie breaking away from zero (so a decimal such as 0.3 becomes exactly 300 000 000 ns despite its binary representation error). None for NaN, an infinity, or a value outside the representable range. A Double carries about 15 significant digits, so a very large duration cannot keep nanosecond precision; the nanosecond is exact only while the whole-second part is below about 9 million seconds.

    TimeDelta::hash

    fn TimeDelta::hash(self : TimeDelta) -> Int

    TimeDelta::hash_combine

    fn TimeDelta::hash_combine(TimeDelta, Hasher) -> Unit

    TimeDelta::hours

    fn TimeDelta::hours(n : Int64) -> TimeDelta?

    The duration of the given number of whole hours, or None if it does not fit in the representable range.

    TimeDelta::is_zero

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

    Whether this duration is exactly zero.

    TimeDelta::max_value

    fn TimeDelta::max_value() -> TimeDelta

    The most positive representable duration, exactly 9_223_372_036_854_774 seconds with no nanosecond remainder: the negation of min_value. The range is part of the type's contract and will not change.

    TimeDelta::microseconds

    fn TimeDelta::microseconds(n : Int64) -> TimeDelta?

    The duration of the given number of whole microseconds, or None if it does not fit in the representable range.

    TimeDelta::milliseconds

    fn TimeDelta::milliseconds(n : Int64) -> TimeDelta?

    The duration of the given number of whole milliseconds, or None if it does not fit in the representable range.

    TimeDelta::min_value

    fn TimeDelta::min_value() -> TimeDelta

    The most negative representable duration, exactly -9_223_372_036_854_774 seconds: the negation of max_value. The range is part of the type's contract and will not change.

    TimeDelta::minutes

    fn TimeDelta::minutes(n : Int64) -> TimeDelta?

    The duration of the given number of whole minutes, or None if it does not fit in the representable range.

    TimeDelta::mul

    fn TimeDelta::mul(self : TimeDelta, scalar : Int) -> TimeDelta

    This duration multiplied by the integer scalar.

    Aborts if it overflows the representable range; use checked_mul to get None instead.

    TimeDelta::nanoseconds

    fn TimeDelta::nanoseconds(n : Int64) -> TimeDelta?

    The duration of the given number of whole nanoseconds, or None if it does not fit in the representable range.

    TimeDelta::neg

    fn TimeDelta::neg(self : TimeDelta) -> TimeDelta

    The negation of this duration. Always representable: the representable range is symmetric around zero specifically so this is total.

    TimeDelta::new

    fn TimeDelta::new(seconds : Int64, nanoseconds : Int) -> TimeDelta?

    The duration of seconds whole seconds plus nanoseconds, which must be in 0..=999_999_999: the sign of the duration is carried entirely by seconds, so new(-1L, 500_000_000) is minus half a second. Returns None if nanoseconds is outside that range or the result does not fit in the representable range.

    TimeDelta::not_equal

    fn TimeDelta::not_equal(x : TimeDelta, y : TimeDelta) -> Bool

    TimeDelta::num_days

    fn TimeDelta::num_days(self : TimeDelta) -> Int64

    The number of whole days in this duration, truncated toward zero.

    TimeDelta::num_hours

    fn TimeDelta::num_hours(self : TimeDelta) -> Int64

    The number of whole hours in this duration, truncated toward zero.

    TimeDelta::num_microseconds

    fn TimeDelta::num_microseconds(self : TimeDelta) -> Int64?

    The number of whole microseconds in this duration, truncated toward zero, or None if it does not fit in Int64.

    TimeDelta::num_milliseconds

    fn TimeDelta::num_milliseconds(self : TimeDelta) -> Int64

    The number of whole milliseconds in this duration, truncated toward zero. Always succeeds: the representable range of TimeDelta is chosen so this count never overflows Int64 (unlike num_microseconds and num_nanoseconds, which can).

    TimeDelta::num_minutes

    fn TimeDelta::num_minutes(self : TimeDelta) -> Int64

    The number of whole minutes in this duration, truncated toward zero.

    TimeDelta::num_nanoseconds

    fn TimeDelta::num_nanoseconds(self : TimeDelta) -> Int64?

    The number of whole nanoseconds in this duration, or None if it does not fit in Int64.

    TimeDelta::num_seconds

    fn TimeDelta::num_seconds(self : TimeDelta) -> Int64

    The number of whole seconds in this duration, truncated toward zero (e.g. a duration of -1.7s reports -1, not -2).

    TimeDelta::num_weeks

    fn TimeDelta::num_weeks(self : TimeDelta) -> Int64

    The number of whole weeks in this duration, truncated toward zero.

    TimeDelta::op_ge

    fn TimeDelta::op_ge(x : TimeDelta, y : TimeDelta) -> Bool

    TimeDelta::op_gt

    fn TimeDelta::op_gt(x : TimeDelta, y : TimeDelta) -> Bool

    TimeDelta::op_le

    fn TimeDelta::op_le(x : TimeDelta, y : TimeDelta) -> Bool

    TimeDelta::op_lt

    fn TimeDelta::op_lt(x : TimeDelta, y : TimeDelta) -> Bool

    TimeDelta::output

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

    TimeDelta::round

    fn TimeDelta::round(self : TimeDelta, granularity : TimeDelta) -> Result[TimeDelta, RoundingError]

    This duration rounded to the nearest multiple of granularity, ties (an exact half-multiple) breaking away from zero. See truncate for the conditions under which granularity is rejected.

    TimeDelta::round_up

    fn TimeDelta::round_up(self : TimeDelta, granularity : TimeDelta) -> Result[TimeDelta, RoundingError]

    This duration rounded up (toward positive infinity) to the nearest multiple of granularity: unchanged if already a multiple, otherwise the next multiple above it. For a negative duration that is toward zero, the same result as truncate. Fails if granularity is rejected (see truncate), or with OutOfRange if rounding up would leave TimeDelta's representable range.

    TimeDelta::seconds

    fn TimeDelta::seconds(n : Int64) -> TimeDelta?

    The duration of the given number of whole seconds, or None if it does not fit in the representable range.

    TimeDelta::sub

    fn TimeDelta::sub(self : TimeDelta, other : TimeDelta) -> TimeDelta

    The difference of two durations.

    Aborts if it overflows the representable range; use checked_sub to get None instead.

    TimeDelta::subsec_microseconds

    fn TimeDelta::subsec_microseconds(self : TimeDelta) -> Int

    The subsec_nanoseconds remainder expressed in whole microseconds, truncated toward zero.

    TimeDelta::subsec_milliseconds

    fn TimeDelta::subsec_milliseconds(self : TimeDelta) -> Int

    The subsec_nanoseconds remainder expressed in whole milliseconds, truncated toward zero.

    TimeDelta::subsec_nanoseconds

    fn TimeDelta::subsec_nanoseconds(self : TimeDelta) -> Int

    The nanosecond remainder such that self.num_seconds() * 1_000_000_000 + self.subsec_nanoseconds() equals this duration's total nanosecond count. Carries the same sign as the overall duration, so it may be negative even though the internal representation's nanosecond component is always non-negative.

    TimeDelta::sum

    fn TimeDelta::sum(deltas : Array[TimeDelta]) -> TimeDelta

    The total of deltas; an empty array totals zero(). The result does not depend on the order of deltas (see checked_sum).

    Aborts if the true total falls outside the representable range; use checked_sum to get None instead.

    TimeDelta::to_string

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

    TimeDelta::truncate

    fn TimeDelta::truncate(self : TimeDelta, granularity : TimeDelta) -> Result[TimeDelta, RoundingError]

    This duration truncated toward zero to the nearest multiple of granularity. Fails with InvalidGranularity if granularity is zero or negative, or MixedGranularity if it mixes a whole-second part with a sub-second remainder (e.g. 1.5 seconds) — see Granularity.

    TimeDelta::weeks

    fn TimeDelta::weeks(n : Int64) -> TimeDelta?

    The duration of the given number of whole weeks, or None if it does not fit in the representable range.

    TimeDelta::zero

    fn TimeDelta::zero() -> TimeDelta

    The duration of zero length; Default::default() returns it.

    Weekday

    pub(all) enum Weekday {
    Mon
    Tue
    Wed
    Thu
    Fri
    Sat
    Sun
    } derive(Eq, Hash,
    Debug
    )

    A day of the week.

    The variant order below has no calendar meaning by itself; use number_from_monday, number_from_sunday, num_days_from_monday, or num_days_from_sunday to get a day-of-week number in a specific counting convention.
    impl Show for Weekday

    Weekday::add_days

    fn Weekday::add_days(self : Weekday, n : Int) -> Weekday

    The weekday n days after self (before it, for a negative n), wrapping around the week in either direction.

    Weekday::days_since

    fn Weekday::days_since(self : Weekday, other : Weekday) -> Int

    The number of days elapsed since other, wrapping forward through the week (always in 0..=6).

    Weekday::equal

    fn Weekday::equal(Weekday, Weekday) -> Bool

    Weekday::from_name

    fn Weekday::from_name(name : String) -> Weekday?

    The weekday named by name: its full English name ("Monday") or its three-letter abbreviation ("Mon"), ignoring ASCII letter case, or None for anything else (including a prefix, an abbreviation of another length such as "Tues", surrounding whitespace, or non-ASCII text).

    Weekday::from_num_days_from_monday

    fn Weekday::from_num_days_from_monday(n : Int) -> Weekday?

    The Weekday whose num_days_from_monday() is n (0 = Mon), or None if n is outside 0..=6.

    Weekday::from_num_days_from_sunday

    fn Weekday::from_num_days_from_sunday(n : Int) -> Weekday?

    The Weekday whose num_days_from_sunday() is n (0 = Sun), or None if n is outside 0..=6.

    Weekday::from_number_from_monday

    fn Weekday::from_number_from_monday(n : Int) -> Weekday?

    The Weekday whose number_from_monday() is n (ISO 8601 numbering: 1 = Mon, 7 = Sun), or None if n is outside 1..=7.

    Weekday::from_number_from_sunday

    fn Weekday::from_number_from_sunday(n : Int) -> Weekday?

    The Weekday whose number_from_sunday() is n (1 = Sun, 7 = Sat), or None if n is outside 1..=7.

    Weekday::hash

    fn Weekday::hash(self : Weekday) -> Int

    Weekday::hash_combine

    fn Weekday::hash_combine(Weekday, Hasher) -> Unit

    Weekday::name

    fn Weekday::name(self : Weekday) -> String

    The English name of the weekday.

    Weekday::not_equal

    fn Weekday::not_equal(x : Weekday, y : Weekday) -> Bool

    Weekday::num_days_from_monday

    fn Weekday::num_days_from_monday(self : Weekday) -> Int

    Day-of-week number counting from Mon = 0.

    Weekday::num_days_from_sunday

    fn Weekday::num_days_from_sunday(self : Weekday) -> Int

    Day-of-week number counting from Sun = 0.

    Weekday::number_from_monday

    fn Weekday::number_from_monday(self : Weekday) -> Int

    ISO 8601 day-of-week number, counting from Mon = 1.

    Weekday::number_from_sunday

    fn Weekday::number_from_sunday(self : Weekday) -> Int

    Day-of-week number counting from Sun = 1.

    Weekday::output

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

    Weekday::pred

    fn Weekday::pred(self : Weekday) -> Weekday

    The previous day, wrapping from Mon back to Sun.

    Weekday::succ

    fn Weekday::succ(self : Weekday) -> Weekday

    The next day, wrapping from Sun back to Mon.

    Weekday::to_repr

    Weekday::to_string

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

    WeekdaySet

    pub struct WeekdaySet {
    // private fields
    } derive(Eq, Hash,
    Debug
    )

    A collection of Weekday values, stored as a 7-bit set.

    Bit i corresponds to the weekday whose Weekday::index() is i (Mon = 0 .. Sun = 6); higher bits are always 0.

    Sets have no total order: the bit layout is a representation detail and the meaningful relation is is_subset.
    impl Show for WeekdaySet

    WeekdaySet::all

    fn WeekdaySet::all() -> WeekdaySet

    The set containing all seven weekdays.

    WeekdaySet::contains

    fn WeekdaySet::contains(self : WeekdaySet, day : Weekday) -> Bool

    Whether the set contains day.

    WeekdaySet::default

    fn WeekdaySet::default() -> WeekdaySet

    WeekdaySet::difference

    fn WeekdaySet::difference(self : WeekdaySet, other : WeekdaySet) -> WeekdaySet

    Weekdays that are in self but not in other.

    WeekdaySet::empty

    fn WeekdaySet::empty() -> WeekdaySet

    The empty set, containing no weekdays; Default::default() returns it.

    WeekdaySet::equal

    fn WeekdaySet::equal(WeekdaySet, WeekdaySet) -> Bool

    WeekdaySet::first

    fn WeekdaySet::first(self : WeekdaySet) -> Weekday?

    The earliest weekday in the set, starting from Monday.

    WeekdaySet::from_array

    fn WeekdaySet::from_array(days : Array[Weekday]) -> WeekdaySet

    A set containing exactly the given weekdays.

    WeekdaySet::hash

    fn WeekdaySet::hash(self : WeekdaySet) -> Int

    WeekdaySet::hash_combine

    fn WeekdaySet::hash_combine(WeekdaySet, Hasher) -> Unit

    WeekdaySet::insert

    fn WeekdaySet::insert(self : WeekdaySet, day : Weekday) -> WeekdaySet

    The set with day added, unchanged if it was already a member.

    WeekdaySet::intersection

    fn WeekdaySet::intersection(self : WeekdaySet, other : WeekdaySet) -> WeekdaySet

    Weekdays that are in both self and other.

    WeekdaySet::is_empty

    fn WeekdaySet::is_empty(self : WeekdaySet) -> Bool

    Whether the set contains no weekdays.

    WeekdaySet::is_subset

    fn WeekdaySet::is_subset(self : WeekdaySet, other : WeekdaySet) -> Bool

    Whether every weekday in self is also in other.

    WeekdaySet::iter

    fn WeekdaySet::iter(self : WeekdaySet, start? : Weekday) -> Iter[Weekday]

    This set's members in cyclic weekday order starting at start (default Mon, which matches to_array), as a standard Iter, usable in a for loop (for day in set.iter(start=Sun)) and with adapters. Use iter_from for a double-ended iterator.

    WeekdaySet::iter_from

    fn WeekdaySet::iter_from(self : WeekdaySet, start : Weekday) -> WeekdaySetIterator

    A double-ended iterator over this set's members in cyclic weekday order starting at start, wrapping from Sun to Mon: a start weekday that is not a member simply begins at the next member. Unlike iter, it also walks from the back (next_back) and reports its length. See WeekdaySetIterator.

    WeekdaySet::last

    fn WeekdaySet::last(self : WeekdaySet) -> Weekday?

    The latest weekday in the set, starting from Sunday.

    WeekdaySet::length

    fn WeekdaySet::length(self : WeekdaySet) -> Int

    The number of weekdays in the set.

    WeekdaySet::not_equal

    fn WeekdaySet::not_equal(x : WeekdaySet, y : WeekdaySet) -> Bool

    WeekdaySet::output

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

    WeekdaySet::remove

    fn WeekdaySet::remove(self : WeekdaySet, day : Weekday) -> WeekdaySet

    The set with day removed, unchanged if it was not a member.

    WeekdaySet::single

    fn WeekdaySet::single(day : Weekday) -> WeekdaySet

    A set containing exactly the given weekday; single_day reads it back.

    WeekdaySet::single_day

    fn WeekdaySet::single_day(self : WeekdaySet) -> Weekday?

    Some(day) if the set contains exactly one weekday, None otherwise; the inverse of WeekdaySet::single.

    WeekdaySet::symmetric_difference

    fn WeekdaySet::symmetric_difference(self : WeekdaySet, other : WeekdaySet) -> WeekdaySet

    Weekdays that are in self or other, but not in both.

    WeekdaySet::to_array

    fn WeekdaySet::to_array(self : WeekdaySet) -> Array[Weekday]

    The weekdays in the set, in Mon..Sun order.

    WeekdaySet::to_string

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

    WeekdaySet::union

    fn WeekdaySet::union(self : WeekdaySet, other : WeekdaySet) -> WeekdaySet

    Weekdays that are in either self or other.

    WeekdaySetIterator

    pub struct WeekdaySetIterator {
    // private fields
    } derive(
    Debug
    )

    An iterator over the members of a WeekdaySet in cyclic weekday order from a chosen start weekday, double-ended: next walks forward from the start (wrapping from Sun to Mon) and next_back walks backward from the end of that cycle. See WeekdaySet::iter_from.

    An iterator is a position that is consumed, the one stateful kind of value in this package: next and next_back advance it in place, iter does not advance it by itself but returns an Iter that shares its state, and the method that creates it (WeekdaySet::iter_from) returns a fresh iterator on every call, leaving the set unchanged.

    WeekdaySetIterator::iter

    This iterator as a standard Iter, so it works in a for loop and with adapters such as map and take. The Iter shares this iterator's state, as for NaiveDateDaysIterator::iter.

    WeekdaySetIterator::length

    fn WeekdaySetIterator::length(self : WeekdaySetIterator) -> Int

    The number of members remaining to be yielded.

    WeekdaySetIterator::next

    The next member from the front of the cycle, or None once every member has been yielded from either end.

    WeekdaySetIterator::next_back

    The next member from the back of the cycle, or None once every member has been yielded from either end.

    YearCe

    pub struct YearCe {
    // private fields
    } derive(Eq, Hash,
    Debug
    )

    A year split around the Common Era: whether it is in the Common Era (is_ce, years 1 and later) and the positive number of the year within that era, so year 0 is 1 BCE. See NaiveDate::year_ce.

    YearCe::equal

    fn YearCe::equal(YearCe, YearCe) -> Bool

    YearCe::hash

    fn YearCe::hash(self : YearCe) -> Int

    YearCe::hash_combine

    fn YearCe::hash_combine(YearCe, Hasher) -> Unit

    YearCe::is_ce

    fn YearCe::is_ce(self : YearCe) -> Bool

    Whether the year is in the Common Era (year 1 and later).

    YearCe::not_equal

    fn YearCe::not_equal(x : YearCe, y : YearCe) -> Bool

    YearCe::to_repr

    YearCe::year

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

    The positive year number within its era.

    is_leap_year

    fn is_leap_year(year : Int) -> Bool

    Whether year is a leap year in the proleptic Gregorian calendar: divisible by 4, except centuries, which must be divisible by 400.