Sign in

    Lampese/mathplotlib/ticker/date does not have a README file

    DateError

    pub(all) suberror DateError {
    InvalidDate(message~ : String)
    InvalidFormat(message~ : String)
    }

    Errors raised while constructing or parsing a date value.

    AutoDateFormatter

    pub struct AutoDateFormatter {
    // private fields
    }

    AutoDateFormatter::as_formatter

    AutoDateFormatter::default_format

    fn AutoDateFormatter::default_format(self : AutoDateFormatter) -> String

    AutoDateFormatter::format_array

    fn AutoDateFormatter::format_array(self : AutoDateFormatter, values : Array[Double], pos? : Int) -> Array[String] raise DateError

    Pass an entire numeric array unchanged to the selected ValuesFunc callback.

    AutoDateFormatter::format_dates

    fn AutoDateFormatter::format_dates(self : AutoDateFormatter, values : Array[DateTime], pos? : Int) -> Array[String] raise DateError

    Pass original date objects to a DatesFunc callback without numeric conversion.

    AutoDateFormatter::format_ticks

    fn AutoDateFormatter::format_ticks(self : AutoDateFormatter, values : Array[Double]) -> Array[String] raise DateError

    Standard Formatter.format_ticks semantics: call each scalar with its index.

    AutoDateFormatter::format_value

    fn AutoDateFormatter::format_value(self : AutoDateFormatter, value : Double, pos? : Int) -> String raise DateError

    AutoDateFormatter::new

    fn AutoDateFormatter::new(locator? : DateLocator, tz? : String, timezone? : DateTimeZone, default_format? : String, usetex? : Bool) -> AutoDateFormatter raise DateError

    Construct a locator-unit formatter and capture the rc format table. Text entries resolve the original tz argument at each call (the current timezone rc if omitted); custom callbacks receive original inputs without resolution. The first scaled key >= the base unit wins, regardless of locator interval. An omitted locator uses the upstream missing-unit fallback of one day.

    test {
    let formatter = @date.AutoDateFormatter::new(
    locator=@date.minute_locator(interval=30),
    )
    assert_eq(formatter.unit_scale(), 1.0 / 1440.0)
    assert_eq(formatter.format_value(0.0), "01 00:00")
    }

    AutoDateFormatter::scaled

    fn AutoDateFormatter::scaled(self : AutoDateFormatter) -> Array[(Double, DateScaleFormat)]

    AutoDateFormatter::unit_scale

    fn AutoDateFormatter::unit_scale(self : AutoDateFormatter) -> Double

    AutoDateFormatter::with_default_format

    fn AutoDateFormatter::with_default_format(self : AutoDateFormatter, format : String) -> AutoDateFormatter

    AutoDateFormatter::with_locator

    fn AutoDateFormatter::with_locator(self : AutoDateFormatter, locator : DateLocator) -> AutoDateFormatter

    Copy the formatter for a new concrete locator.

    AutoDateFormatter::with_locator_unit

    fn AutoDateFormatter::with_locator_unit(self : AutoDateFormatter, unit : Double) -> AutoDateFormatter

    Bind a custom locator's base unit. Standard axes derive this automatically from the actual major/minor locator, including after replacement or zoom.

    AutoDateFormatter::with_offset

    fn AutoDateFormatter::with_offset(self : AutoDateFormatter, offset_minutes : Int) -> AutoDateFormatter raise DateError

    AutoDateFormatter::with_scale

    fn AutoDateFormatter::with_scale(self : AutoDateFormatter, scale : Double, format : DateScaleFormat) -> AutoDateFormatter raise DateError

    Set one scale entry while retaining the remaining dictionary.

    AutoDateFormatter::with_scaled

    fn AutoDateFormatter::with_scaled(self : AutoDateFormatter, entries : Array[(Double, DateScaleFormat)]) -> AutoDateFormatter raise DateError

    Replace the scale dictionary. Repeated keys take the last value. Negative and infinite keys are supported; NaN keys are rejected as unordered.

    AutoDateFormatter::with_timezone

    fn AutoDateFormatter::with_timezone(self : AutoDateFormatter, timezone : DateTimeZone) -> AutoDateFormatter

    AutoDateFormatter::with_usetex

    fn AutoDateFormatter::with_usetex(self : AutoDateFormatter, usetex : Bool) -> AutoDateFormatter

    AutoDateLocator

    pub struct AutoDateLocator {
    // private fields
    }

    AutoDateLocator::as_locator

    fn AutoDateLocator::as_locator(self : AutoDateLocator) -> DateLocator

    Adapt this object while sharing its live selection state. Independent configuration/state copies are available through copy(); axes copy on install.

    AutoDateLocator::copy

    Copy configuration and the last selection without sharing mutable state.

    AutoDateLocator::frequency

    AutoDateLocator::get_locator

    fn AutoDateLocator::get_locator(self : AutoDateLocator, first : DateTime, last : DateTime) -> DateLocator raise DateError

    Select a concrete calendar locator from local DateTime endpoints. Reuses the public recurrence wrapper, captured timezone and microsecond generators.

    AutoDateLocator::get_locator_for_range

    fn AutoDateLocator::get_locator_for_range(self : AutoDateLocator, lower : Double, upper : Double) -> DateLocator raise DateError

    Select from numeric UTC day bounds, interpreting both in this locator's zone.

    AutoDateLocator::interval_multiples

    fn AutoDateLocator::interval_multiples(self : AutoDateLocator) -> Bool

    AutoDateLocator::intervals

    fn AutoDateLocator::intervals(self : AutoDateLocator, frequency : DateFrequency) -> Array[Int]

    AutoDateLocator::max_ticks

    fn AutoDateLocator::max_ticks(self : AutoDateLocator, frequency : DateFrequency) -> Int

    AutoDateLocator::maxticks

    fn AutoDateLocator::maxticks(self : AutoDateLocator) -> Array[(DateFrequency, Int)]

    AutoDateLocator::minticks

    fn AutoDateLocator::minticks(self : AutoDateLocator) -> Int

    AutoDateLocator::new

    fn AutoDateLocator::new(context? : DateParserContext, tz? : String, timezone? : DateTimeZone, minticks? : Int, maxticks? : DateMaxTicks, interval_multiples? : Bool) -> AutoDateLocator raise DateError

    Construct the upstream calendar-aware automatic selector. Configuration is copied; selection updates frequency/interval/warnings independently of it. context supplies host-local now for the year-multiple branch only.

    test {
    let locator = @date.AutoDateLocator::new(maxticks=@date.All(5))
    let first = @date.datetime(2024, 1, 1).to_ordinal()
    let last = @date.datetime(2024, 6, 1).to_ordinal()
    assert_true(!locator.tick_values(first, last).is_empty())
    assert_eq(locator.frequency(), @date.Month)
    }
    Capture an explicit timezone or the current timezone rc at construction.

    AutoDateLocator::nonsingular

    fn AutoDateLocator::nonsingular(_self : AutoDateLocator, lower : Double, upper : Double) -> (Double, Double)

    Expand a single finite value by two years each side, or supply the numeric 1970-01-01/02 range for nonfinite bounds. This does not select a frequency.

    AutoDateLocator::selected_interval

    fn AutoDateLocator::selected_interval(self : AutoDateLocator) -> Int

    Return the last intervald candidate, before multiples become range selectors.

    AutoDateLocator::tick_values

    fn AutoDateLocator::tick_values(self : AutoDateLocator, lower : Double, upper : Double) -> Array[Double] raise DateError

    Generate ticks in the port's input range order. Singular inputs are passed directly to selection; nonsingular() is a separate autoscale operation.

    AutoDateLocator::unit_scale

    fn AutoDateLocator::unit_scale(self : AutoDateLocator) -> Double

    AutoDateLocator::warnings

    Return diagnostics from the last selection, without printing warnings.

    AutoDateLocator::with_interval_multiples

    fn AutoDateLocator::with_interval_multiples(self : AutoDateLocator, enabled : Bool) -> AutoDateLocator

    Change alignment while retaining intervald, including any customization.

    AutoDateLocator::with_intervals

    fn AutoDateLocator::with_intervals(self : AutoDateLocator, frequency : DateFrequency, values : Array[Int]) -> AutoDateLocator raise DateError

    Keep the given order, as upstream intervald does; empty/nonpositive lists raise without changing this object. Other interval tables remain unchanged.

    AutoDateLocator::with_maxticks

    fn AutoDateLocator::with_maxticks(self : AutoDateLocator, value : DateMaxTicks) -> AutoDateLocator raise DateError

    AutoDateLocator::with_minticks

    fn AutoDateLocator::with_minticks(self : AutoDateLocator, count : Int) -> AutoDateLocator raise DateError

    AutoDateLocator::with_offset

    fn AutoDateLocator::with_offset(self : AutoDateLocator, offset_minutes : Int) -> AutoDateLocator raise DateError

    AutoDateLocator::with_timezone

    fn AutoDateLocator::with_timezone(self : AutoDateLocator, timezone : DateTimeZone) -> AutoDateLocator

    AutoDateWarning

    pub(all) enum AutoDateWarning {
    IntervalFallback(DateFrequency, Int)
    DistantMicroseconds
    } derive(Eq,
    Debug
    )

    AutoDateWarning::equal

    AutoDateWarning::not_equal

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

    ConciseDateConverter

    pub struct ConciseDateConverter {
    // private fields
    }

    Date conversion with configurable six-level concise axis labels.

    ConciseDateConverter::as_converter

    ConciseDateConverter::axisinfo

    ConciseDateConverter::convert

    fn ConciseDateConverter::convert(self : ConciseDateConverter, values : Array[DateTime]) -> Array[Double]

    ConciseDateConverter::convert_value

    fn ConciseDateConverter::convert_value(self : ConciseDateConverter, value : DateTime) -> Double

    ConciseDateConverter::default_unit

    fn ConciseDateConverter::default_unit(self : ConciseDateConverter, value : DateTime) -> DateTimeZone

    ConciseDateConverter::default_units

    fn ConciseDateConverter::default_units(self : ConciseDateConverter, values : Array[DateTime]) -> DateTimeZone?

    ConciseDateConverter::new

    fn ConciseDateConverter::new(formats? : Array[String], zero_formats? : Array[String], offset_formats? : Array[String], show_offset? : Bool, interval_multiples? : Bool) -> ConciseDateConverter

    Copy optional format arrays. As in the pinned upstream constructor, its superclass initialization resets interval_multiples to true. Format-array validation occurs in axisinfo when the formatter is constructed.

    ConciseDateFormatter

    pub struct ConciseDateFormatter {
    // private fields
    }

    A batch date formatter with Matplotlib's six-level concise label rules. format_ticks updates the last offset; configuration copies are independent.

    ConciseDateFormatter::as_formatter

    Return a standalone date formatter suitable for Axis::set_date_formatter.

    ConciseDateFormatter::default_format

    fn ConciseDateFormatter::default_format(self : ConciseDateFormatter) -> String

    Return the format used for individual values (upstream defaultfmt).

    ConciseDateFormatter::format_data_short

    fn ConciseDateFormatter::format_data_short(self : ConciseDateFormatter, value : Double) -> String raise DateError

    Format a cursor/status value with a complete date and second-resolution time.

    ConciseDateFormatter::format_ticks

    fn ConciseDateFormatter::format_ticks(self : ConciseDateFormatter, values : Array[Double], inverted? : Bool) -> Array[String] raise DateError

    Format a batch and update its shared date text. inverted selects the first supplied tick for the offset instead of the last, matching an inverted axis. Empty batches clear the offset; invalid dates raise without changing it.

    ConciseDateFormatter::format_value

    fn ConciseDateFormatter::format_value(self : ConciseDateFormatter, value : Double) -> String

    Format one value using the default year format, as upstream call does.

    ConciseDateFormatter::formats

    fn ConciseDateFormatter::formats(self : ConciseDateFormatter) -> Array[String]

    ConciseDateFormatter::get_offset

    fn ConciseDateFormatter::get_offset(self : ConciseDateFormatter) -> String

    Return the last successful batch's shared date text, initially empty.

    ConciseDateFormatter::offset_formats

    fn ConciseDateFormatter::offset_formats(self : ConciseDateFormatter) -> Array[String]

    ConciseDateFormatter::show_offset

    fn ConciseDateFormatter::show_offset(self : ConciseDateFormatter) -> Bool

    ConciseDateFormatter::with_default_format

    fn ConciseDateFormatter::with_default_format(self : ConciseDateFormatter, format : String) -> ConciseDateFormatter

    Return a copy with a different individual-value format. Batch labels and format_data_short retain their own formats.

    ConciseDateFormatter::with_offset

    fn ConciseDateFormatter::with_offset(self : ConciseDateFormatter, offset_minutes : Int) -> ConciseDateFormatter raise DateError

    Return a configuration copy using a fixed label offset, with no prior batch.

    ConciseDateFormatter::with_show_offset

    fn ConciseDateFormatter::with_show_offset(self : ConciseDateFormatter, show_offset : Bool) -> ConciseDateFormatter

    Return a configuration copy controlling shared date text visibility.

    ConciseDateFormatter::with_timezone

    Return a configuration copy using exact transition-aware label conversion.

    ConciseDateFormatter::with_usetex

    fn ConciseDateFormatter::with_usetex(self : ConciseDateFormatter, usetex : Bool) -> ConciseDateFormatter

    Return a configuration copy controlling upstream TeX string output.

    ConciseDateFormatter::zero_formats

    fn ConciseDateFormatter::zero_formats(self : ConciseDateFormatter) -> Array[String]

    DateAxisInfo

    pub struct DateAxisInfo {
    // private fields
    }

    Date-specific AxisInfo. Locator and formatter getters share this object's live selection; copy() creates an independent, correctly rebound pair.

    DateAxisInfo::copy

    DateAxisInfo::default_limits

    fn DateAxisInfo::default_limits(self : DateAxisInfo) -> (DateTime, DateTime)

    DateAxisInfo::label

    fn DateAxisInfo::label(self : DateAxisInfo) -> String

    DateAxisInfo::major_formatter

    fn DateAxisInfo::major_formatter(self : DateAxisInfo) -> DateFormatter

    DateAxisInfo::major_locator

    fn DateAxisInfo::major_locator(self : DateAxisInfo) -> DateLocator

    DateConverter

    pub struct DateConverter {
    // private fields
    }

    Typed date conversion and default axis configuration. DateTime values carry explicit UTC offsets; empty arrays have no inferred unit.

    DateConverter::axisinfo

    fn DateConverter::axisinfo(self : DateConverter, unit? : DateTimeZone) -> DateAxisInfo raise DateError

    Return fresh default locators and formatter, without converting or locking the epoch. Limits remain Gregorian date values until the axis needs them.

    DateConverter::convert

    fn DateConverter::convert(_self : DateConverter, values : Array[DateTime]) -> Array[Double]

    Convert flat, typed datetime values through the shared epoch implementation. The inferred label timezone never changes numeric instants.

    DateConverter::convert_value

    fn DateConverter::convert_value(_self : DateConverter, value : DateTime) -> Double

    DateConverter::copy

    DateConverter::default_unit

    fn DateConverter::default_unit(_self : DateConverter, value : DateTime) -> DateTimeZone

    Retain a rule zone, or construct the value's exact fixed-second offset unit. This does not read or lock the numeric epoch.

    DateConverter::default_units

    fn DateConverter::default_units(self : DateConverter, values : Array[DateTime]) -> DateTimeZone?

    Infer the first date's unit. There are no missing or heterogeneous entries in Array[DateTime]; an empty array has no unit.

    DateConverter::interval_multiples

    fn DateConverter::interval_multiples(self : DateConverter) -> Bool

    DateConverter::new

    fn DateConverter::new(interval_multiples? : Bool) -> DateConverter

    Configure automatic date labels with the original default interval tables.

    test {
    let converter = @date.DateConverter::new()
    let info = converter.axisinfo()
    let values = converter.convert([
    @date.datetime(2024, 1, 1),
    @date.datetime(2024, 1, 2, hour=16),
    ])
    let ticks = info.major_locator().tick_values(values[0], values[1])
    assert_true(!info.major_formatter().format_values(ticks).is_empty())
    }

    DateFormatter

    pub struct DateFormatter {
    format : String
    offset_minutes : Int
    timezone : DateTimeZone?
    // private fields
    }

    A date formatter that converts numeric UTC day values to strings in a fixed offset or a rule zone. %z emits +HHMM[SS]; %Z uses the TZif designation when available, otherwise UTC or UTC+HH:MM[:SS].

    DateFormatter::copy

    Copy a date formatter without sharing mutable format arrays.

    DateFormatter::format

    fn DateFormatter::format(self : DateFormatter) -> String

    DateFormatter::format_value

    fn DateFormatter::format_value(self : DateFormatter, value : Double) -> String

    DateFormatter::format_values

    fn DateFormatter::format_values(self : DateFormatter, values : Array[Double], inverted? : Bool) -> Array[String]

    Format a complete tick list using scalar or concise date rules. A failed batch falls back to individual value labels and has no shared offset.

    DateFormatter::offset_label

    fn DateFormatter::offset_label(self : DateFormatter, values : Array[Double], inverted? : Bool) -> String

    Return shared date text for this tick list, empty for scalar formatters.

    DateFormatter::offset_minutes

    fn DateFormatter::offset_minutes(self : DateFormatter) -> Int

    Return whole offset minutes (truncated toward zero for TZif history). When a zone is configured, use timezone for exact instant-dependent offsets.

    DateFormatter::timezone

    fn DateFormatter::timezone(self : DateFormatter) -> DateTimeZone?

    Return the initially configured zone, if any. Auto/Concise with omitted or named tz re-resolve it while formatting; use with_timezone for a fixed binding.

    DateFormatter::with_locator_unit

    fn DateFormatter::with_locator_unit(self : DateFormatter, unit : Double) -> DateFormatter

    Bind an automatic formatter to the actual locator's base unit. Scalar and concise formatters retain their configuration. Used by axis adapters.

    DateFormatter::with_offset

    fn DateFormatter::with_offset(self : DateFormatter, offset_minutes : Int) -> DateFormatter raise DateError

    Return a copy that formats instants in a fixed offset east of UTC. Reject offsets outside -1439..1439 minutes.

    test {
    let formatter = @date.date_formatter("%H:%M %z %Z").with_offset(345)
    assert_eq(formatter.offset_minutes(), 345)
    assert_eq(formatter.format_value(0.0), "05:45 +0545 UTC+05:45")
    }

    DateFormatter::with_timezone

    fn DateFormatter::with_timezone(self : DateFormatter, timezone : DateTimeZone) -> DateFormatter

    Return a copy that formats UTC instants using a transition/TZif zone. Label conversion retains historical seconds and future footer rules.

    DateFormatter::with_usetex

    fn DateFormatter::with_usetex(self : DateFormatter, usetex : Bool) -> DateFormatter

    Return a formatter selecting upstream TeX string output.

    DateFrequency

    pub(all) enum DateFrequency {
    Year
    Month
    Day
    Hour
    Minute
    Second
    Microsecond
    } derive(Compare, Eq,
    Debug
    )

    DateFrequency::compare

    DateFrequency::equal

    DateFrequency::not_equal

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

    DateFrequency::op_ge

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

    DateFrequency::op_gt

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

    DateFrequency::op_le

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

    DateFrequency::op_lt

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

    DateLocator

    pub struct DateLocator {
    kind : LocatorKind
    interval : Int
    selector : Int
    secondary : Int
    selector_enabled : Bool
    offset_minutes : Int
    // private fields
    }

    A calendar locator for UTC numeric dates, capturing its display timezone.

    DateLocator::automatic_locator

    fn DateLocator::automatic_locator(self : DateLocator) -> AutoDateLocator?

    Return the live automatic selector behind this adapter, if any.

    DateLocator::copy

    fn DateLocator::copy(self : DateLocator) -> DateLocator

    Copy a locator, isolating automatic selection state and private arrays. RRuleLocator adapters retain their shared wrapper handle.

    DateLocator::interval

    fn DateLocator::interval(self : DateLocator) -> Int

    Legacy integer interval. Fractional microsecond intervals truncate and large ones saturate to Int32::MAX; interval_value() retains the exact Double value.

    DateLocator::interval_value

    fn DateLocator::interval_value(self : DateLocator) -> Double

    Return the exact interval, including fractional microseconds.

    DateLocator::kind

    fn DateLocator::kind(self : DateLocator) -> LocatorKind

    DateLocator::microsecond_locator

    fn DateLocator::microsecond_locator(self : DateLocator) -> MicrosecondLocator?

    DateLocator::nonsingular

    fn DateLocator::nonsingular(self : DateLocator, lower : Double, upper : Double) -> (Double, Double)

    Return locator-specific nonsingular bounds. Automatic locators expand exact points by two years; explicit units use the base unit and interval.

    DateLocator::offset_minutes

    fn DateLocator::offset_minutes(self : DateLocator) -> Int

    Return configured whole minutes, truncated toward zero for TZif history. A configured timezone supplies the exact offsets used for expansion.

    DateLocator::rrule_locator

    fn DateLocator::rrule_locator(self : DateLocator) -> RRuleLocator?

    Return the live wrapper locator behind this adapter, if any.

    DateLocator::selector

    fn DateLocator::selector(self : DateLocator) -> Int

    Return the smallest selector, or 0 when no filter is configured.

    DateLocator::tick_values

    fn DateLocator::tick_values(self : DateLocator, lower : Double, upper : Double) -> Array[Double]

    Generate up to 100000 ticks in input range order. With no matching dates, return the input endpoints. Invalid ordinals return an empty array.

    Recurrences use an explicit dtstart when configured; otherwise they use Matplotlib's calendar-expanded window as their anchor. Year locators include aligned years outside the range. Microsecond locators include adjacent multiples on either side, within years 1..9999.

    DateLocator::tick_values_checked

    fn DateLocator::tick_values_checked(self : DateLocator, lower : Double, upper : Double) -> Array[Double] raise DateError

    Generate calendar ticks while preserving date conversion and selection errors. The legacy tick_values convenience method returns [] on these errors.

    DateLocator::timezone

    fn DateLocator::timezone(self : DateLocator) -> DateTimeZone?

    Return the explicit transition-aware timezone used for tick conversion, if configured.

    DateLocator::unit_scale

    fn DateLocator::unit_scale(self : DateLocator) -> Double

    Return the locator's base unit in days, independent of its interval.

    DateLocator::with_offset

    fn DateLocator::with_offset(self : DateLocator, offset_minutes : Int) -> DateLocator raise DateError

    Return a copy of this locator whose calendar boundaries use a fixed UTC offset. The emitted numeric ticks remain UTC Matplotlib ordinals.

    test {
    let locator = try! @date.hour_locator().with_offset(90)
    assert_eq(locator.offset_minutes(), 90)
    }

    DateLocator::with_timezone

    fn DateLocator::with_timezone(self : DateLocator, timezone : DateTimeZone) -> DateLocator

    Return a copy whose calendar candidates resolve with an explicit transition table. Recurrence locators generate local candidates in the same zone, so a spring gap is skipped and a fall fold can emit both UTC instants.

    DateMaxTicks

    pub(all) enum DateMaxTicks {
    All(Int)
    ByFrequency(Array[(DateFrequency, Int)])
    } derive(Eq,
    Debug
    )

    DateMaxTicks::equal

    DateMaxTicks::not_equal

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

    DateParseWarning

    pub(all) enum DateParseWarning {
    UnknownTimezone(String)
    } derive(Eq,
    Debug
    )

    DateParseWarning::equal

    DateParseWarning::not_equal

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

    DateParserContext

    pub struct DateParserContext {
    // private fields
    }

    Clock and host-local rules for date-string parsing. Explicit contexts avoid system files and use the same TZif/POSIX engine as ordinary date axes.

    DateParserContext::from_posix

    fn DateParserContext::from_posix(spec : String, clock? : () -> Int64) -> DateParserContext raise DateError

    Supply a POSIX TZ specification, including standard/daylight names and rules.

    DateParserContext::from_tzif

    fn DateParserContext::from_tzif(data : Bytes, clock? : () -> Int64) -> DateParserContext raise DateError

    Supply raw TZif bytes and, optionally, a Unix-millisecond clock. Construction does not read the clock or lock the numeric date epoch.

    DateParserContext::system

    fn DateParserContext::system(clock? : () -> Int64) -> DateParserContext raise DateError

    Resolve TZ/TZDIR or /etc/localtime using the runtime's file capability. Unavailable host-local rules require an explicit context; no UTC fallback.

    DateParserContext::utc

    fn DateParserContext::utc(clock? : () -> Int64) -> DateParserContext

    DateParserContext::with_local_info

    fn DateParserContext::with_local_info(self : DateParserContext, standard_seconds : Int, daylight_seconds : Int, names : Array[String]) -> DateParserContext raise DateError

    Supply a host's explicit standard/daylight descriptor instead of the pinned CPython sampling profile. Rules still provide actual clock and DST queries. The two names are copied at construction; no clock or epoch is read.

    DateScaleFormat

    pub(all) enum DateScaleFormat {
    Text(String)
    Func((Double, Int?) -> String)
    ValuesFunc((Array[Double], Int?) -> Array[String])
    DatesFunc((Array[DateTime], Int?) -> Array[String])
    }

    String or callable entries in AutoDateFormatter.scaled. Scalar callbacks receive the original numeric value and optional position; they own TeX output. Array callbacks are used by the explicit format_array/format_dates methods.

    DateStringParser

    pub struct DateStringParser {
    // private fields
    }

    Default dateutil grammar with an explicit clock/local-zone context. The reference year and local-name descriptor are captured at construction.

    DateStringParser::copy

    DateStringParser::local_names

    fn DateStringParser::local_names(self : DateStringParser) -> Array[String]

    DateStringParser::local_offsets

    fn DateStringParser::local_offsets(self : DateStringParser) -> (Int, Int)

    DateStringParser::new

    fn DateStringParser::new(context? : DateParserContext, reference_year? : Int) -> DateStringParser raise DateError

    Construct with host-local rules, or provide an explicit portable context.

    test {
    let context = @date.DateParserContext::from_posix(
    "EST5EDT,M3.2.0/2,M11.1.0/2",
    clock=fn() { 1781524800000L },
    )
    let parser = @date.DateStringParser::new(context~)
    let value = @date.datestr2num("Nov 3, 2024 01:30 EST", parser~)
    assert_eq(@date.num2date(value).hour(), 6)
    }

    DateStringParser::parse

    fn DateStringParser::parse(self : DateStringParser, text : String, default_date? : DateTime) -> DateTime raise DateError

    DateStringParser::parse_many

    fn DateStringParser::parse_many(self : DateStringParser, texts : Array[String], default_date? : DateTime) -> Array[DateTime] raise DateError

    DateStringParser::reference_year

    fn DateStringParser::reference_year(self : DateStringParser) -> Int

    DateStringParser::to_number

    fn DateStringParser::to_number(self : DateStringParser, text : String, default_date? : DateTime) -> Double raise DateError

    DateStringParser::to_numbers

    fn DateStringParser::to_numbers(self : DateStringParser, texts : Array[String], default_date? : DateTime) -> Array[Double] raise DateError

    Preserve datestr2num's explicit-default scalar loop and no-default NumPy vectorization probe, conversion order, and first-aware mixed-array behavior.

    DateStringParser::warnings

    Diagnostics from the last operation, including warnings emitted before a later parse/conversion error. Returned arrays do not alias parser state.

    DateTime

    pub struct DateTime {
    year : Int
    month : Int
    day : Int
    hour : Int
    minute : Int
    second : Int
    microsecond : Int
    offset_minutes : Int
    // private fields
    }

    A Gregorian date and time used by the date ticker.

    offset_seconds stores an exact offset east of UTC, including historical seconds. The numeric representation follows Matplotlib: days since 1970-01-01 UTC, with the local time converted back to its instant before encoding.

    DateTime::add_relative_delta

    fn DateTime::add_relative_delta(self : DateTime, delta : RelativeDelta) -> DateTime raise DateError

    Apply calendar replacements/relative fields, then weekday movement. Months clamp to month end. Relative time uses exact wall-clock microseconds and the retained rule zone; folds reset to the earlier occurrence and gaps use the dateutil post-transition offset. Neither rc timezone nor epoch is read.

    DateTime::add_timedelta

    fn DateTime::add_timedelta(self : DateTime, delta : TimeDelta) -> DateTime raise DateError

    Add a duration in local calendar time, preserving all microsecond digits. A retained rule zone resolves the new offset: folds choose the earlier instant and gaps use dateutil's post-transition offset. Calendar overflow raises DateError. Fixed offsets retain their original offset.

    DateTime::day

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

    DateTime::hour

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

    DateTime::microsecond

    fn DateTime::microsecond(self : DateTime) -> Int

    DateTime::minute

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

    DateTime::month

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

    DateTime::offset_minutes

    fn DateTime::offset_minutes(self : DateTime) -> Int

    Return whole offset minutes, truncated toward zero for historical seconds. Use offset_seconds() for exact arithmetic.

    DateTime::offset_seconds

    fn DateTime::offset_seconds(self : DateTime) -> Int

    Return the exact fixed offset east of UTC, in seconds.

    test {
    let value = @date.datetime(1900, 1, 1, offset_seconds=561)
    assert_eq(value.offset_seconds(), 561)
    assert_eq(@date.format_date(value.with_offset(0), "%H:%M:%S"), "23:50:39")
    }

    DateTime::second

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

    DateTime::sub_relative_delta

    fn DateTime::sub_relative_delta(self : DateTime, delta : RelativeDelta) -> DateTime raise DateError

    DateTime::timezone

    fn DateTime::timezone(self : DateTime) -> DateTimeZone?

    Return the retained rule zone, if converted using with_timezone/to_datetime. Explicit fixed-offset conversions clear this reference.

    DateTime::timezone_abbreviation

    fn DateTime::timezone_abbreviation(self : DateTime) -> String?

    Return the TZif designation, if this value was converted through a TZif zone.

    DateTime::to_ordinal

    fn DateTime::to_ordinal(self : DateTime) -> Double

    Convert this value to Matplotlib's floating-point day representation.

    DateTime::weekday

    fn DateTime::weekday(self : DateTime) -> Int

    Return the weekday using Monday=0 through Sunday=6, like Python datetime.

    DateTime::with_offset

    fn DateTime::with_offset(self : DateTime, offset_minutes : Int) -> DateTime raise DateError

    Convert this instant to a different fixed UTC offset. The conversion preserves all six microsecond digits even far from epoch.

    test {
    let value = @date.datetime(2243, 10, 17, microsecond=123456)
    let shifted = value.with_offset(-480)
    assert_eq(shifted.day(), 16)
    assert_eq(shifted.hour(), 16)
    assert_eq(shifted.microsecond(), 123456)
    }

    DateTime::with_offset_seconds

    fn DateTime::with_offset_seconds(self : DateTime, offset_seconds : Int) -> DateTime raise DateError

    Convert this instant to an exact offset, preserving all microsecond digits.

    DateTime::with_timezone

    fn DateTime::with_timezone(self : DateTime, zone : DateTimeZone) -> DateTime raise DateError

    Convert an instant represented by this value to a transition-aware zone.

    DateTime::year

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

    DateTimeZone

    pub struct DateTimeZone {
    // private fields
    }

    A transition-aware zone, optionally loaded from caller-supplied IANA TZif bytes.

    The transition array must be strictly increasing in UTC time. Before the first transition, initial_offset_seconds applies; each transition then replaces the previous offset.

    DateTimeZone::initial_offset_minutes

    fn DateTimeZone::initial_offset_minutes(self : DateTimeZone) -> Int

    Return initial whole minutes, truncated toward zero; use initial_offset_seconds for precision.

    DateTimeZone::initial_offset_seconds

    fn DateTimeZone::initial_offset_seconds(self : DateTimeZone) -> Int

    Return the exact initial offset east of UTC, in seconds.

    DateTimeZone::offset_at

    fn DateTimeZone::offset_at(self : DateTimeZone, value : Double) -> Int raise DateError

    Resolve whole offset minutes, truncated toward zero. Use offset_seconds_at for precision.

    DateTimeZone::offset_seconds_at

    fn DateTimeZone::offset_seconds_at(self : DateTimeZone, value : Double) -> Int raise DateError

    Resolve the exact seconds offset for a UTC ordinal.

    DateTimeZone::to_datetime

    fn DateTimeZone::to_datetime(self : DateTimeZone, value : Double) -> DateTime raise DateError

    Convert a UTC ordinal to local Gregorian fields using this zone.

    DateTimeZone::to_ordinal

    fn DateTimeZone::to_ordinal(self : DateTimeZone, value : DateTime) -> Double raise DateError

    Convert local fields to a UTC ordinal using this zone's transition rules.

    The local value's offset selects one side of an ambiguous fall transition. A local time inside a skipped spring transition raises DateError.

    DateTimeZone::transitions

    Return a copy of the explicit transition table within years 1..9999. POSIX footer events are evaluated on demand and are not materialized here.

    DateTimeZone::unit_equal

    fn DateTimeZone::unit_equal(self : DateTimeZone, other : DateTimeZone) -> Bool

    Unit equality for retained rule-zone identities and fixed-offset snapshots. Fixed offsets compare by seconds, including independently constructed values; rule-based zones retain their object identity.

    DayLocator

    pub struct DayLocator {
    // private fields
    }

    Matplotlib DayLocator backed by the shared recurrence locator.

    DayLocator::as_locator

    fn DayLocator::as_locator(self : DayLocator) -> DateLocator

    DayLocator::as_rrule_locator

    fn DayLocator::as_rrule_locator(self : DayLocator) -> RRuleLocator

    Retain this locator's shared wrapper and display timezone.

    DayLocator::interval

    fn DayLocator::interval(self : DayLocator) -> Int

    DayLocator::new

    fn DayLocator::new(bymonthday? : Array[Int], bymonthday_value? : Int, interval? : Int, tz? : String, timezone? : DateTimeZone, context? : DateParserContext, null? : Array[String]) -> DayLocator raise DateError

    Daily ticks default to all month days. Negative days count from month end. context supplies host-local now. null names pass explicit None selectors.

    test {
    let context = @date.DateParserContext::utc(clock=fn() { 1781524800123L })
    let locator = @date.DayLocator::new(bymonthday_value=-1, tz="UTC", context~)
    let values = locator.tick_values(
    @date.RRuleDateTime::naive(@date.datetime(2024, 1, 1)),
    @date.RRuleDateTime::naive(@date.datetime(2024, 3, 1)),
    )
    assert_eq(values.length(), 2)
    }

    DayLocator::rule

    fn DayLocator::rule(self : DayLocator) -> RRuleWrapper

    Return the shared mutable recurrence wrapper.

    DayLocator::tick_values

    fn DayLocator::tick_values(self : DayLocator, first : RRuleDateTime, last : RRuleDateTime) -> Array[Double] raise DateError

    DayLocator::timezone

    fn DayLocator::timezone(self : DayLocator) -> DateTimeZone

    DayLocator::unit_scale

    fn DayLocator::unit_scale(self : DayLocator) -> Double

    DayLocator::with_offset

    fn DayLocator::with_offset(self : DayLocator, offset_minutes : Int) -> DayLocator raise DateError

    DayLocator::with_timezone

    fn DayLocator::with_timezone(self : DayLocator, timezone : DateTimeZone) -> DayLocator

    HourLocator

    pub struct HourLocator {
    // private fields
    }

    Matplotlib HourLocator backed by the shared recurrence locator.

    HourLocator::as_locator

    fn HourLocator::as_locator(self : HourLocator) -> DateLocator

    HourLocator::as_rrule_locator

    fn HourLocator::as_rrule_locator(self : HourLocator) -> RRuleLocator

    Retain this locator's shared wrapper and display timezone.

    HourLocator::interval

    fn HourLocator::interval(self : HourLocator) -> Int

    HourLocator::new

    fn HourLocator::new(byhour? : Array[Int], byhour_value? : Int, interval? : Int, tz? : String, timezone? : DateTimeZone, context? : DateParserContext, null? : Array[String]) -> HourLocator raise DateError

    Hourly ticks default to every hour, at minute/second zero. context supplies host-local now. null names pass explicit None selectors.

    test {
    let context = @date.DateParserContext::utc(clock=fn() { 1781524800123L })
    let locator = @date.HourLocator::new(byhour=[0, 12], tz="UTC", context~)
    let values = locator.tick_values(
    @date.RRuleDateTime::naive(@date.datetime(2024, 1, 1)),
    @date.RRuleDateTime::naive(@date.datetime(2024, 1, 2)),
    )
    assert_eq(values.length(), 3)
    }

    HourLocator::rule

    Return the shared mutable recurrence wrapper.

    HourLocator::tick_values

    fn HourLocator::tick_values(self : HourLocator, first : RRuleDateTime, last : RRuleDateTime) -> Array[Double] raise DateError

    HourLocator::timezone

    fn HourLocator::timezone(self : HourLocator) -> DateTimeZone

    HourLocator::unit_scale

    fn HourLocator::unit_scale(self : HourLocator) -> Double

    HourLocator::with_offset

    fn HourLocator::with_offset(self : HourLocator, offset_minutes : Int) -> HourLocator raise DateError

    HourLocator::with_timezone

    fn HourLocator::with_timezone(self : HourLocator, timezone : DateTimeZone) -> HourLocator

    LocatorKind

    pub(all) enum LocatorKind {
    Automatic
    Days
    BusinessDays
    Years
    Months
    Weekdays
    NthWeekdays
    Recurrence
    Hours
    Minutes
    Seconds
    Microseconds
    }

    Calendar units supported by the explicit date locators.

    MicrosecondLocator

    pub struct MicrosecondLocator {
    // private fields
    }

    Matplotlib MicrosecondLocator with a finite positive Double interval. Date conversion precedes the midnight-relative MultipleLocator grid.

    MicrosecondLocator::as_locator

    Adapt the exact interval while retaining the legacy integer projection.

    MicrosecondLocator::interval

    fn MicrosecondLocator::interval(self : MicrosecondLocator) -> Double

    MicrosecondLocator::new

    fn MicrosecondLocator::new(interval? : Double, tz? : String, timezone? : DateTimeZone, context? : DateParserContext) -> MicrosecondLocator raise DateError

    Capture the display zone before validating the interval. context is only used for host interpretation of naive values in a first-aware mixed array.

    test {
    let locator = @date.MicrosecondLocator::new(interval=0.5, tz="UTC")
    let first = @date.RRuleDateTime::naive(@date.datetime(1970, 1, 1))
    let last = @date.RRuleDateTime::naive(
    @date.datetime(1970, 1, 1, microsecond=3),
    )
    assert_eq(locator.tick_values(first, last).length(), 9)
    assert_eq(locator.as_locator().interval_value(), 0.5)
    }

    MicrosecondLocator::nonsingular

    fn MicrosecondLocator::nonsingular(self : MicrosecondLocator, lower : Double, upper : Double) -> (Double, Double)

    MicrosecondLocator::tick_values

    fn MicrosecondLocator::tick_values(self : MicrosecondLocator, first : RRuleDateTime, last : RRuleDateTime) -> Array[Double] raise DateError

    Return source-order ascending ticks, including neighboring points outside years 1..9999. Direct reversed bounds keep the original first origin.

    MicrosecondLocator::timezone

    MicrosecondLocator::unit_scale

    fn MicrosecondLocator::unit_scale(_self : MicrosecondLocator) -> Double

    MicrosecondLocator::with_offset

    fn MicrosecondLocator::with_offset(self : MicrosecondLocator, offset_minutes : Int) -> MicrosecondLocator raise DateError

    MicrosecondLocator::with_timezone

    fn MicrosecondLocator::with_timezone(self : MicrosecondLocator, timezone : DateTimeZone) -> MicrosecondLocator

    MinuteLocator

    pub struct MinuteLocator {
    // private fields
    }

    Matplotlib MinuteLocator backed by the shared recurrence locator.

    MinuteLocator::as_locator

    fn MinuteLocator::as_locator(self : MinuteLocator) -> DateLocator

    MinuteLocator::as_rrule_locator

    fn MinuteLocator::as_rrule_locator(self : MinuteLocator) -> RRuleLocator

    Retain this locator's shared wrapper and display timezone.

    MinuteLocator::interval

    fn MinuteLocator::interval(self : MinuteLocator) -> Int

    MinuteLocator::new

    fn MinuteLocator::new(byminute? : Array[Int], byminute_value? : Int, interval? : Int, tz? : String, timezone? : DateTimeZone, context? : DateParserContext, null? : Array[String]) -> MinuteLocator raise DateError

    Minute ticks default to every minute, at second zero. context supplies host-local now. null names pass explicit None selectors.

    test {
    let context = @date.DateParserContext::utc(clock=fn() { 1781524800123L })
    let locator = @date.MinuteLocator::new(byminute=[0, 30], tz="UTC", context~)
    let values = locator.tick_values(
    @date.RRuleDateTime::naive(@date.datetime(2024, 1, 1)),
    @date.RRuleDateTime::naive(@date.datetime(2024, 1, 1, hour=1)),
    )
    assert_eq(values.length(), 3)
    }

    MinuteLocator::rule

    Return the shared mutable recurrence wrapper.

    MinuteLocator::tick_values

    fn MinuteLocator::tick_values(self : MinuteLocator, first : RRuleDateTime, last : RRuleDateTime) -> Array[Double] raise DateError

    MinuteLocator::timezone

    fn MinuteLocator::timezone(self : MinuteLocator) -> DateTimeZone

    MinuteLocator::unit_scale

    fn MinuteLocator::unit_scale(self : MinuteLocator) -> Double

    MinuteLocator::with_offset

    fn MinuteLocator::with_offset(self : MinuteLocator, offset_minutes : Int) -> MinuteLocator raise DateError

    MinuteLocator::with_timezone

    fn MinuteLocator::with_timezone(self : MinuteLocator, timezone : DateTimeZone) -> MinuteLocator

    MonthLocator

    pub struct MonthLocator {
    // private fields
    }

    Matplotlib MonthLocator backed by the shared recurrence locator.

    MonthLocator::as_locator

    fn MonthLocator::as_locator(self : MonthLocator) -> DateLocator

    MonthLocator::as_rrule_locator

    fn MonthLocator::as_rrule_locator(self : MonthLocator) -> RRuleLocator

    Retain this locator's shared wrapper and display timezone.

    MonthLocator::interval

    fn MonthLocator::interval(self : MonthLocator) -> Int

    MonthLocator::new

    fn MonthLocator::new(bymonth? : Array[Int], bymonth_value? : Int, bymonthday? : Array[Int], bymonthday_value? : Int, interval? : Int, tz? : String, timezone? : DateTimeZone, context? : DateParserContext, null? : Array[String]) -> MonthLocator raise DateError

    Monthly ticks; bymonth defaults to all months and bymonthday defaults to 1. context supplies host-local now. null names pass explicit None selectors.

    test {
    let context = @date.DateParserContext::utc(clock=fn() { 1781524800123L })
    let locator = @date.MonthLocator::new(tz="UTC", context~)
    let values = locator.tick_values(
    @date.RRuleDateTime::naive(@date.datetime(2024, 1, 1)),
    @date.RRuleDateTime::naive(@date.datetime(2024, 3, 1)),
    )
    assert_eq(values.length(), 3)
    }

    MonthLocator::rule

    Return the shared mutable recurrence wrapper.

    MonthLocator::tick_values

    fn MonthLocator::tick_values(self : MonthLocator, first : RRuleDateTime, last : RRuleDateTime) -> Array[Double] raise DateError

    MonthLocator::timezone

    fn MonthLocator::timezone(self : MonthLocator) -> DateTimeZone

    MonthLocator::unit_scale

    fn MonthLocator::unit_scale(self : MonthLocator) -> Double

    MonthLocator::with_offset

    fn MonthLocator::with_offset(self : MonthLocator, offset_minutes : Int) -> MonthLocator raise DateError

    MonthLocator::with_timezone

    fn MonthLocator::with_timezone(self : MonthLocator, timezone : DateTimeZone) -> MonthLocator

    RRule

    pub struct RRule {
    // private fields
    }

    A reusable recurrence rule with a concrete start date.

    RRule mirrors the query-oriented part of dateutil.rrule: construct a rule once, then ask for occurrences in a bounded interval. The locator adapter remains available when the rule is attached to an axis.

    RRule::after

    fn RRule::after(self : RRule, value : DateTime, inc? : Bool) -> DateTime? raise DateError

    Return the first occurrence after value, or the equal occurrence when inc is true. The search is bounded by the supported Gregorian range.

    RRule::all

    fn RRule::all(self : RRule) -> Array[DateTime] raise DateError

    Return all occurrences from dtstart through year 9999.

    Results are capped at 100000 occurrences, the same safety limit used by DateLocator::tick_values. Rules without count or until can therefore represent an unbounded recurrence while keeping this eager query finite.

    RRule::before

    fn RRule::before(self : RRule, value : DateTime, inc? : Bool) -> DateTime? raise DateError

    Return the last occurrence before value, or the equal occurrence when inc is true. The search is bounded by the supported Gregorian range.

    RRule::between

    fn RRule::between(self : RRule, after : DateTime, before : DateTime, inc? : Bool) -> Array[DateTime] raise DateError

    Return occurrences between two date-times.

    The bounds are exclusive by default, matching dateutil.rrule. Set inc to include occurrences exactly equal to either bound. An inverted interval returns an empty array.

    RRule::cache_enabled

    fn RRule::cache_enabled(self : RRule) -> Bool

    Return whether this rule shares a lazily generated occurrence cache.

    RRule::count

    fn RRule::count(self : RRule) -> Int?

    Return the optional occurrence limit.

    RRule::dtstart

    fn RRule::dtstart(self : RRule) -> DateTime

    Return the recurrence start date.

    RRule::frequency

    fn RRule::frequency(self : RRule) -> RRuleFrequency

    Return the recurrence frequency.

    RRule::interval

    fn RRule::interval(self : RRule) -> Int

    Return the positive calendar or clock interval.

    RRule::iter

    fn RRule::iter(self : RRule) -> Iter[DateTime]

    Return an independent lazy reader starting at DTSTART. Native Iter supports next, take, map and for. It stops at count/until or the supported calendar boundary; unlike eager arrays it has no 100000 occurrence cap.

    test {
    let rule = @date.rrule(@date.Daily, @date.datetime(2024, 1, 1), cache=true)
    assert_eq(rule.iter().take(3).to_array().map(value => value.day()), [1, 2, 3])
    assert_eq(rule.iter().next().unwrap().day(), 1)
    }

    RRule::iter_after

    fn RRule::iter_after(self : RRule, value : DateTime, count? : Int, inc? : Bool) -> Iter[DateTime]

    Lazily yield occurrences after an instant, including equality with inc. An omitted count streams to the rule's natural end; nonpositive counts return an empty iterator. Each call has an independent reader position.

    RRule::locator

    fn RRule::locator(self : RRule) -> DateLocator

    Return the axis locator represented by this rule.

    RRule::replace

    fn RRule::replace(self : RRule, frequency? : RRuleFrequency, dtstart? : DateTime, interval? : Int, wkst? : Int, bymonth? : Array[Int], bymonthday? : Array[Int], byyearday? : Array[Int], byweekno? : Array[Int], byeaster? : Array[Int], byweekday? : Array[Int], byhour? : Array[Int], byminute? : Array[Int], bysecond? : Array[Int], bysetpos? : Array[Int], count? : Int, until? : DateTime, clear? : Array[String], cache? : Bool) -> RRule raise DateError

    Return a rule with selected fields replaced.

    Omitted fields keep their current values. Selector arrays are copied and validated again, so the returned rule is independent of both the original rule and the caller's arrays. Pass selector names through clear to remove an existing selector before applying replacements. This typed form covers the common immutable dateutil.rrule.replace workflow while keeping the clear operation explicit in MoonBit's optional-argument type system. The cache setting is retained unless replaced; a fresh cache is always used.

    RRule::until

    fn RRule::until(self : RRule) -> DateTime?

    Return the inclusive upper date-time bound, when configured.

    RRule::with_offset

    fn RRule::with_offset(self : RRule, offset_minutes : Int) -> RRule raise DateError

    Return a copy whose recurrence dates use a fixed UTC offset. The cache setting is preserved, with independent empty cache state.

    RRule::with_timezone

    fn RRule::with_timezone(self : RRule, timezone : DateTimeZone) -> RRule

    Return a copy whose recurrence fields are interpreted in a transition-aware local timezone. Calendar candidates are still generated in local time; emitted ticks remain UTC Matplotlib ordinals. The cache setting is preserved with a new empty prefix.

    test {
    let zone = try! @date.timezone(-300, transitions=[
    try! @date.timezone_transition(@date.datetime(2024, 3, 10, hour=7), -240),
    ])
    let rule = try! @date.rrule(
    @date.RRuleFrequency::Daily,
    @date.datetime(2024, 3, 9, hour=2, offset_minutes=-300),
    byhour=[2],
    ).with_timezone(zone)
    assert_eq(rule.locator().offset_minutes(), -300)
    }

    RRule::wkst

    fn RRule::wkst(self : RRule) -> Int

    Return the week-start selector (Monday=0 through Sunday=6).

    RRule::xafter

    fn RRule::xafter(self : RRule, value : DateTime, count? : Int, inc? : Bool) -> Array[DateTime] raise DateError

    Return successive occurrences after value.

    This eager array form covers the useful query semantics of dateutil.rrule.xafter; an omitted count is capped at 100000 results.

    RRuleDateIterator

    pub struct RRuleDateIterator {
    // private fields
    }

    Lazy naive recurrence snapshot with checked reads. The first next() may report an unreachable clock cycle; a failed or exhausted reader then ends.

    RRuleDateIterator::next

    Read the next naive date. Creating the reader performs no clock/epoch access and does not raise an iteration error. A read error terminates this reader.

    RRuleDateTime

    pub struct RRuleDateTime {
    // private fields
    }

    Explicit awareness at rrulewrapper's boundary. DateTime continues to store ordinary aware instants; a naive rule date stores only its local fields.

    RRuleDateTime::aware

    fn RRuleDateTime::aware(value : DateTime) -> RRuleDateTime

    Retain the instant and its rule-zone identity, or capture a fixed-offset snapshot when the DateTime has no retained rule zone.

    RRuleDateTime::date

    Local fields plus an exact offset for aware values. Naive values use offset zero as a field carrier; retain RRuleDateTime when awareness matters.

    RRuleDateTime::from_local

    fn RRuleDateTime::from_local(value : DateTime, timezone : DateTimeZone, fold? : Bool) -> RRuleDateTime raise DateError

    Attach a zone to local fields. Imaginary gaps use the post-transition offset; fold selects dateutil wall-time behavior (earlier/later for ordinary folds). This does not convert through numeric date coordinates or read the epoch.

    RRuleDateTime::is_naive

    fn RRuleDateTime::is_naive(self : RRuleDateTime) -> Bool

    RRuleDateTime::naive

    fn RRuleDateTime::naive(value : DateTime) -> RRuleDateTime

    Drop the timezone without changing local fields.

    RRuleDateTime::timezone

    fn RRuleDateTime::timezone(self : RRuleDateTime) -> DateTimeZone?

    RRuleDateTime::to_ordinal

    fn RRuleDateTime::to_ordinal(self : RRuleDateTime) -> Double raise DateError

    Convert to numeric dates, checking aware UTC overflow before reading epoch.

    RRuleFrequency

    pub(all) enum RRuleFrequency {
    Yearly
    Monthly
    Weekly
    Daily
    Hourly
    Minutely
    Secondly
    }

    Calendar frequencies used by rrule_locator (from years to seconds).

    RRuleLocator

    pub struct RRuleLocator {
    // private fields
    }

    A Matplotlib RRuleLocator retaining a live mutable wrapper. Its display timezone is captured independently of the wrapper's base/effective zone.

    RRuleLocator::as_locator

    fn RRuleLocator::as_locator(self : RRuleLocator) -> DateLocator

    Share the wrapper with numeric axes. copy() of this DateLocator retains that handle, so locator window updates and caller set calls remain observable.

    RRuleLocator::interval

    fn RRuleLocator::interval(self : RRuleLocator) -> Int

    RRuleLocator::new

    fn RRuleLocator::new(rule : RRuleWrapper, tz? : String, timezone? : DateTimeZone) -> RRuleLocator raise DateError

    RRuleLocator::rule

    Return the shared wrapper; later set calls affect this locator and adapters.

    RRuleLocator::tick_values

    fn RRuleLocator::tick_values(self : RRuleLocator, first : RRuleDateTime, last : RRuleDateTime) -> Array[Double] raise DateError

    Expand the range by relativedelta, rebuilding the shared wrapper as the original locator does. Direct bounds retain their own awareness and zones.

    test {
    let first = @date.RRuleDateTime::naive(@date.datetime(2024, 1, 1))
    let last = @date.RRuleDateTime::naive(@date.datetime(2024, 1, 3))
    let rule = @date.RRuleWrapper::new(@date.Daily, dtstart=first)
    let locator = @date.RRuleLocator::new(rule, tz="UTC")
    assert_eq(locator.tick_values(first, last).length(), 3)
    rule.set(frequency=@date.Hourly, interval=12)
    assert_eq(locator.as_locator().interval(), 12)
    }

    Empty rules return the original endpoints. Unlike the numeric adapter, reversed direct bounds follow the source's signed calendar expansion.

    RRuleLocator::timezone

    fn RRuleLocator::timezone(self : RRuleLocator) -> DateTimeZone

    RRuleLocator::unit_for_frequency

    fn RRuleLocator::unit_for_frequency(frequency : RRuleFrequency) -> Double

    RRuleLocator::unit_scale

    fn RRuleLocator::unit_scale(self : RRuleLocator) -> Double

    RRuleLocator::with_offset

    fn RRuleLocator::with_offset(self : RRuleLocator, offset_minutes : Int) -> RRuleLocator raise DateError

    RRuleLocator::with_timezone

    fn RRuleLocator::with_timezone(self : RRuleLocator, timezone : DateTimeZone) -> RRuleLocator

    RRuleSet

    pub struct RRuleSet {
    // private fields
    }

    A reusable set of recurrence rules and explicit dates.

    Inclusion rules and dates are merged in UTC instant order. Duplicate instants are emitted once, and exclusion rules or dates remove an instant from every inclusion source. Adding a source reuses the existing RRule query implementation; the set does not duplicate recurrence generation.

    RRuleSet::after

    fn RRuleSet::after(self : RRuleSet, value : DateTime, inc? : Bool) -> DateTime? raise DateError

    Return the first occurrence after value, or the equal occurrence when inc is true. Excluded candidates are skipped one instant at a time.

    RRuleSet::all

    fn RRuleSet::all(self : RRuleSet) -> Array[DateTime] raise DateError

    Return all occurrences through year 9999, capped at 100000 results.

    RRuleSet::before

    fn RRuleSet::before(self : RRuleSet, value : DateTime, inc? : Bool) -> DateTime? raise DateError

    Return the last occurrence before value, or the equal occurrence when inc is true. Excluded candidates are skipped one instant at a time.

    RRuleSet::between

    fn RRuleSet::between(self : RRuleSet, after : DateTime, before : DateTime, inc? : Bool) -> Array[DateTime] raise DateError

    Return occurrences between two date-times.

    The bounds are exclusive by default, matching RRule::between; set inc to include occurrences exactly equal to either bound. Inclusion sources are merged and deduplicated before exclusion sources are applied.

    RRuleSet::cache_enabled

    fn RRuleSet::cache_enabled(self : RRuleSet) -> Bool

    Return whether this set caches a shared occurrence prefix.

    RRuleSet::exdate

    fn RRuleSet::exdate(self : RRuleSet, date : DateTime) -> Unit

    Add an explicit date whose instant is excluded from the set.

    RRuleSet::exrule

    fn RRuleSet::exrule(self : RRuleSet, rule : RRule) -> Unit

    Add a recurrence rule whose occurrences are excluded from the set.

    RRuleSet::iter

    fn RRuleSet::iter(self : RRuleSet) -> Iter[DateTime]

    Lazily merge inclusion sources, deduplicate exact UTC instants, and apply exclusions. Each reader snapshots the set's sources when created. Adding a source invalidates future cached queries; existing readers keep their snapshot. No eager array cap is imposed on this native Iter.

    test {
    let set = @date.rruleset(cache=true)
    set.rrule(@date.rrule(@date.Daily, @date.datetime(2024, 1, 1), count=3))
    set.exdate(@date.datetime(2024, 1, 2))
    assert_eq(set.iter().to_array().map(value => value.day()), [1, 3])
    }

    RRuleSet::iter_after

    fn RRuleSet::iter_after(self : RRuleSet, value : DateTime, count? : Int, inc? : Bool) -> Iter[DateTime]

    Lazily yield set occurrences after value. Nonpositive count gives an empty iterator; omitting count consumes through the sources' natural end.

    RRuleSet::rdate

    fn RRuleSet::rdate(self : RRuleSet, date : DateTime) -> Unit

    Add an inclusive explicit date to the set.

    RRuleSet::rrule

    fn RRuleSet::rrule(self : RRuleSet, rule : RRule) -> Unit

    Add an inclusive recurrence rule to the set.

    RRuleSet::xafter

    fn RRuleSet::xafter(self : RRuleSet, value : DateTime, count? : Int, inc? : Bool) -> Array[DateTime] raise DateError

    Return successive occurrences after value, up to count results.

    With no count, the result is capped at 100000 entries. The sequence keeps the same inclusion and exclusion semantics as RRuleSet::after.

    RRuleWrapper

    pub struct RRuleWrapper {
    // private fields
    }

    Mutable Matplotlib rrulewrapper. The underlying recurrence stays naive; selected query methods attach the current effective timezone on return.

    RRuleWrapper::after

    fn RRuleWrapper::after(self : RRuleWrapper, value : RRuleDateTime, inc? : Bool) -> RRuleDateTime? raise DateError

    First recurrence after a date, or at the date when inc=true. An aware wrapper raises when no match exists, matching the original attach(None).

    RRuleWrapper::base_timezone

    fn RRuleWrapper::base_timezone(self : RRuleWrapper) -> DateTimeZone?

    RRuleWrapper::before

    fn RRuleWrapper::before(self : RRuleWrapper, value : RRuleDateTime, inc? : Bool) -> RRuleDateTime? raise DateError

    RRuleWrapper::between

    fn RRuleWrapper::between(self : RRuleWrapper, after : RRuleDateTime, before : RRuleDateTime, inc? : Bool) -> Array[RRuleDateTime] raise DateError

    Recurrences between local-normalized bounds. Both ends are exclusive by default. The underlying comparison order is before, then after.

    RRuleWrapper::cache_enabled

    fn RRuleWrapper::cache_enabled(self : RRuleWrapper) -> Bool

    RRuleWrapper::checked_raw_iter

    fn RRuleWrapper::checked_raw_iter(self : RRuleWrapper) -> RRuleDateIterator

    Snapshot the successful core and its existing cache, deferring validation to next(). Later wrapper.set calls do not change this reader's recurrence.

    test {
    let rule = @date.RRuleWrapper::new(
    @date.Minutely,
    dtstart=@date.RRuleDateTime::naive(@date.datetime(2024, 1, 1, hour=12)),
    interval=1440,
    byhour=[12],
    byminute=[0],
    count=2,
    cache=true,
    )
    let reader = rule.checked_raw_iter()
    assert_eq(reader.next().unwrap().date().day(), 1)
    rule.set(byhour=[13])
    assert_eq(reader.next().unwrap().date().day(), 2)
    assert_true(
    try {
    ignore(rule.occurrence_count())
    false
    } catch {
    _ => true
    },
    )
    }

    RRuleWrapper::copy

    Independent construction arrays and empty cache; base/context handles are retained. This explicit copy is a typed snapshot, including failed-set state.

    RRuleWrapper::count_limit

    fn RRuleWrapper::count_limit(self : RRuleWrapper) -> Int?

    RRuleWrapper::dtstart

    fn RRuleWrapper::dtstart(self : RRuleWrapper) -> RRuleDateTime

    RRuleWrapper::frequency

    fn RRuleWrapper::frequency(self : RRuleWrapper) -> RRuleFrequency

    RRuleWrapper::interval

    fn RRuleWrapper::interval(self : RRuleWrapper) -> Int

    RRuleWrapper::new

    fn RRuleWrapper::new(frequency : RRuleFrequency, timezone? : DateTimeZone, context? : DateParserContext, dtstart? : RRuleDateTime, until? : RRuleDateTime, interval? : Int, wkst? : Int, count? : Int, bymonth? : Array[Int], bymonthday? : Array[Int], bymonth_value? : Int, bymonthday_value? : Int, byyearday? : Array[Int], byweekno? : Array[Int], byeaster? : Array[Int], byweekday? : Array[Int], byhour? : Array[Int], byminute? : Array[Int], bysecond? : Array[Int], bysetpos? : Array[Int], byweekdays? : Array[RelativeWeekday], cache? : Bool, null? : Array[String]) -> RRuleWrapper raise DateError

    Construct with optional explicit base zone and deterministic host clock. dtstart may be omitted. null names pass Python-style None; null dtstart/until reproduce the wrapper's checked date-normalization error. Configuration arrays are retained for later set calls; core query selectors are snapshots. bymonth_value/bymonthday_value retain scalar keyword forms for YearLocator.

    test {
    let start = @date.RRuleDateTime::naive(@date.datetime(2024, 1, 1))
    let rule = @date.RRuleWrapper::new(@date.Daily, dtstart=start, count=3)
    assert_eq(
    rule.xafter(start, count=2, inc=true).map(value => value.date().day()),
    [1, 2],
    )
    rule.set(interval=2)
    assert_eq(rule.raw_iter().to_array().map(value => value.date().day()), [
    1, 3, 5,
    ])
    }

    RRuleWrapper::occurrence_count

    fn RRuleWrapper::occurrence_count(self : RRuleWrapper) -> Int64 raise DateError

    Count the underlying recurrence to its natural end, preserving cache behavior. Unreachable cross-field clock masks raise as the source count() does.

    RRuleWrapper::raw_iter

    fn RRuleWrapper::raw_iter(self : RRuleWrapper) -> Iter[RRuleDateTime]

    Explicit access to a native, nonraising Iter snapshot of naive dates. checked_raw_iter() preserves checked iteration errors; this legacy extension represents unreachable clock masks as an empty stream.

    RRuleWrapper::raw_rule

    fn RRuleWrapper::raw_rule(self : RRuleWrapper) -> RRule

    Snapshot of the underlying naive recurrence. Public RRule ordinal adapters retain their existing behavior; raw_iter provides an epoch-free date stream.

    RRuleWrapper::set

    fn RRuleWrapper::set(self : RRuleWrapper, frequency? : RRuleFrequency, dtstart? : RRuleDateTime, until? : RRuleDateTime, interval? : Int, wkst? : Int, count? : Int, bymonth? : Array[Int], bymonthday? : Array[Int], bymonth_value? : Int, bymonthday_value? : Int, byyearday? : Array[Int], byweekno? : Array[Int], byeaster? : Array[Int], byweekday? : Array[Int], byhour? : Array[Int], byminute? : Array[Int], bysecond? : Array[Int], bysetpos? : Array[Int], byweekdays? : Array[RelativeWeekday], cache? : Bool, null? : Array[String]) -> Unit raise DateError

    Update the stored construction arguments and rebuild the naive recurrence. Follows the original failure stages: normalization can leave new arguments; a later core error can also leave new timezone metadata with the old rule.

    RRuleWrapper::timezone

    fn RRuleWrapper::timezone(self : RRuleWrapper) -> DateTimeZone?

    RRuleWrapper::until

    RRuleWrapper::xafter

    fn RRuleWrapper::xafter(self : RRuleWrapper, value : RRuleDateTime, count? : Int, inc? : Bool) -> Array[RRuleDateTime] raise DateError

    Eager typed xafter companion. It attaches the effective zone when present; raw_iter exposes the underlying naive stream. Eager arrays stop at 100000.

    RelativeDelta

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

    Calendar-relative changes and absolute field replacements. Fractional time components remain separate until normalized or applied; months are calendar months. Construction and inspection do not read the date epoch or timezone rc.
    impl Eq for RelativeDelta

    RelativeDelta::abs

    RelativeDelta::add

    Add relative components; the right operand supplies non-None absolute fields and weekday, and supplies leapdays when nonzero. Inputs remain unchanged.

    RelativeDelta::add_timedelta

    fn RelativeDelta::add_timedelta(self : RelativeDelta, delta : TimeDelta) -> RelativeDelta raise DateError

    RelativeDelta::between

    fn RelativeDelta::between(first : DateTime, second : DateTime) -> RelativeDelta raise DateError

    Construct first - second using calendar years/months and the remaining wall or instant duration. Matching rule-zone handles follow datetime's same-tzinfo semantics. Construction does not read the date epoch or display timezone rc.

    RelativeDelta::day

    fn RelativeDelta::day(self : RelativeDelta) -> Int?

    RelativeDelta::days

    fn RelativeDelta::days(self : RelativeDelta) -> Double

    RelativeDelta::divided

    fn RelativeDelta::divided(self : RelativeDelta, factor : Double) -> RelativeDelta raise DateError

    Divide through the original reciprocal-and-multiply path. Each relative component is truncated independently; absolute fields and leapdays persist.

    RelativeDelta::equal

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

    RelativeDelta::has_time

    fn RelativeDelta::has_time(self : RelativeDelta) -> Bool

    RelativeDelta::hour

    fn RelativeDelta::hour(self : RelativeDelta) -> Int?

    RelativeDelta::hours

    fn RelativeDelta::hours(self : RelativeDelta) -> Double

    RelativeDelta::is_zero

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

    RelativeDelta::leapdays

    fn RelativeDelta::leapdays(self : RelativeDelta) -> Double

    RelativeDelta::microsecond

    fn RelativeDelta::microsecond(self : RelativeDelta) -> Int?

    RelativeDelta::microseconds

    fn RelativeDelta::microseconds(self : RelativeDelta) -> Double

    RelativeDelta::minute

    fn RelativeDelta::minute(self : RelativeDelta) -> Int?

    RelativeDelta::minutes

    fn RelativeDelta::minutes(self : RelativeDelta) -> Double

    RelativeDelta::month

    fn RelativeDelta::month(self : RelativeDelta) -> Int?

    RelativeDelta::months

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

    RelativeDelta::negated

    fn RelativeDelta::negated(self : RelativeDelta) -> RelativeDelta raise DateError

    Negate only relative fields. Absolute fields, leapdays and weekday retain their meaning even when a delta is used in datetime subtraction.

    RelativeDelta::new

    fn RelativeDelta::new(years? : Int64, months? : Int64, days? : Double, weeks? : Double, leapdays? : Double, hours? : Double, minutes? : Double, seconds? : Double, microseconds? : Double, year? : Int, month? : Int, day? : Int, hour? : Int, minute? : Int, second? : Int, microsecond? : Int, weekday? : Int, on_weekday? : RelativeWeekday, yearday? : Int, nlyearday? : Int) -> RelativeDelta raise DateError

    Construct dateutil's relative/absolute calendar fields. Relative years and months are Int64; fractional day/time fields are finite Double. Absolute fields are stored without datetime validation until application, including year/month/day=0 fallback. Use either weekday (-7..6 tuple index) or the on_weekday object form. nlyearday takes precedence over a nonzero yearday.

    RelativeDelta::normalized

    fn RelativeDelta::normalized(self : RelativeDelta) -> RelativeDelta raise DateError

    Return integer-valued relative day/time components using dateutil's staged decimal rounding. Absolute fields, leapdays and weekday remain unchanged.

    test {
    let delta = @date.RelativeDelta::new(days=1.5, hours=2.0).normalized()
    assert_eq((delta.days(), delta.hours()), (1.0, 14.0))
    let next = @date.datetime(2024, 1, 31).add_relative_delta(
    @date.RelativeDelta::new(months=1L),
    )
    assert_eq((next.month(), next.day()), (2, 29))
    }

    RelativeDelta::not_equal

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

    RelativeDelta::scaled

    fn RelativeDelta::scaled(self : RelativeDelta, factor : Double) -> RelativeDelta raise DateError

    Scale through float multiplication and truncate each relative component independently, including for factor=1. Absolute fields/leapdays/weekday persist. Integer carries are exact before storing typed day/time components.

    RelativeDelta::second

    fn RelativeDelta::second(self : RelativeDelta) -> Int?

    RelativeDelta::seconds

    fn RelativeDelta::seconds(self : RelativeDelta) -> Double

    RelativeDelta::subtract

    fn RelativeDelta::subtract(self : RelativeDelta, other : RelativeDelta) -> RelativeDelta raise DateError

    Subtract relative fields. Absolute fields/weekday prefer the left operand; leapdays also prefer the left nonzero value, as in dateutil.sub.

    RelativeDelta::weekday

    RelativeDelta::weeks

    fn RelativeDelta::weeks(self : RelativeDelta) -> Double

    Integral-valued Double, matching truncation in dateutil's weeks property.

    RelativeDelta::with_weeks

    fn RelativeDelta::with_weeks(self : RelativeDelta, weeks : Double) -> RelativeDelta raise DateError

    Return a copy with the weeks property replaced, retaining the old day remainder. This property setter does not normalize other relative fields.

    RelativeDelta::year

    fn RelativeDelta::year(self : RelativeDelta) -> Int?

    RelativeDelta::years

    fn RelativeDelta::years(self : RelativeDelta) -> Int64

    RelativeWeekday

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

    dateutil weekday with an optional relative occurrence. None and zero apply as +1; the weekday object's equality still distinguishes their stored values.

    RelativeWeekday::equal

    RelativeWeekday::new

    fn RelativeWeekday::new(weekday : Int, nth? : Int) -> RelativeWeekday

    Construct the weekday object form. As in dateutil.weekday, arbitrary integer indices are retained; applying a delta uses modulo-seven calendar movement.

    RelativeWeekday::not_equal

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

    RelativeWeekday::nth

    fn RelativeWeekday::nth(self : RelativeWeekday) -> Int?

    RelativeWeekday::weekday

    fn RelativeWeekday::weekday(self : RelativeWeekday) -> Int

    RelativeWeekday::with_nth

    fn RelativeWeekday::with_nth(self : RelativeWeekday, nth : Int) -> RelativeWeekday

    SecondLocator

    pub struct SecondLocator {
    // private fields
    }

    Matplotlib SecondLocator backed by the shared recurrence locator.

    SecondLocator::as_locator

    fn SecondLocator::as_locator(self : SecondLocator) -> DateLocator

    SecondLocator::as_rrule_locator

    fn SecondLocator::as_rrule_locator(self : SecondLocator) -> RRuleLocator

    Retain this locator's shared wrapper and display timezone.

    SecondLocator::interval

    fn SecondLocator::interval(self : SecondLocator) -> Int

    SecondLocator::new

    fn SecondLocator::new(bysecond? : Array[Int], bysecond_value? : Int, interval? : Int, tz? : String, timezone? : DateTimeZone, context? : DateParserContext, null? : Array[String]) -> SecondLocator raise DateError

    Second ticks default to every second. context supplies host-local now. null names pass explicit None selectors.

    test {
    let context = @date.DateParserContext::utc(clock=fn() { 1781524800123L })
    let locator = @date.SecondLocator::new(bysecond=[0, 30], tz="UTC", context~)
    let values = locator.tick_values(
    @date.RRuleDateTime::naive(@date.datetime(2024, 1, 1)),
    @date.RRuleDateTime::naive(@date.datetime(2024, 1, 1, minute=1)),
    )
    assert_eq(values.length(), 3)
    }

    SecondLocator::rule

    Return the shared mutable recurrence wrapper.

    SecondLocator::tick_values

    fn SecondLocator::tick_values(self : SecondLocator, first : RRuleDateTime, last : RRuleDateTime) -> Array[Double] raise DateError

    SecondLocator::timezone

    fn SecondLocator::timezone(self : SecondLocator) -> DateTimeZone

    SecondLocator::unit_scale

    fn SecondLocator::unit_scale(self : SecondLocator) -> Double

    SecondLocator::with_offset

    fn SecondLocator::with_offset(self : SecondLocator, offset_minutes : Int) -> SecondLocator raise DateError

    SecondLocator::with_timezone

    fn SecondLocator::with_timezone(self : SecondLocator, timezone : DateTimeZone) -> SecondLocator

    TimeDelta

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

    A normalized microsecond duration with Python timedelta's full day range. The three components avoid overflowing a single Int64 microsecond count.

    TimeDelta::compare

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

    TimeDelta::days

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

    TimeDelta::equal

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

    TimeDelta::microseconds

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

    TimeDelta::not_equal

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

    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::seconds

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

    TimeDelta::total_seconds

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

    Return total seconds as a float, retaining the sign of tiny negative values.

    TimeZoneTransition

    pub struct TimeZoneTransition {
    // private fields
    }

    A UTC instant at which a fixed-offset time zone changes its offset.

    The transition instant is stored as exact UTC microseconds, independent of the selected epoch. The seconds offset applies at and after that instant.

    TimeZoneTransition::at

    fn TimeZoneTransition::at(self : TimeZoneTransition) -> Double

    Return the UTC ordinal at which this transition takes effect.

    TimeZoneTransition::offset_minutes

    fn TimeZoneTransition::offset_minutes(self : TimeZoneTransition) -> Int

    Return whole offset minutes, truncated toward zero. Use offset_seconds for precision.

    TimeZoneTransition::offset_seconds

    fn TimeZoneTransition::offset_seconds(self : TimeZoneTransition) -> Int

    Return the exact offset that takes effect at this transition.

    WeekdayLocator

    pub struct WeekdayLocator {
    // private fields
    }

    Matplotlib WeekdayLocator backed by the shared recurrence locator.

    WeekdayLocator::as_locator

    fn WeekdayLocator::as_locator(self : WeekdayLocator) -> DateLocator

    WeekdayLocator::as_rrule_locator

    fn WeekdayLocator::as_rrule_locator(self : WeekdayLocator) -> RRuleLocator

    Retain this locator's shared wrapper and display timezone.

    WeekdayLocator::interval

    fn WeekdayLocator::interval(self : WeekdayLocator) -> Int

    WeekdayLocator::new

    fn WeekdayLocator::new(byweekday? : Array[Int], byweekday_value? : Int, byweekdays? : Array[RelativeWeekday], on_weekday? : RelativeWeekday, interval? : Int, tz? : String, timezone? : DateTimeZone, context? : DateParserContext, null? : Array[String]) -> WeekdayLocator raise DateError

    Weekday ticks default to Tuesday (Monday=0). Daily frequency ignores nth. context supplies host-local now. null names pass explicit None selectors.

    test {
    let context = @date.DateParserContext::utc(clock=fn() { 1781524800123L })
    let locator = @date.WeekdayLocator::new(tz="UTC", context~)
    let values = locator.tick_values(
    @date.RRuleDateTime::naive(@date.datetime(2024, 1, 1)),
    @date.RRuleDateTime::naive(@date.datetime(2024, 1, 8)),
    )
    assert_eq(values.length(), 1)
    }

    WeekdayLocator::rule

    Return the shared mutable recurrence wrapper.

    WeekdayLocator::tick_values

    fn WeekdayLocator::tick_values(self : WeekdayLocator, first : RRuleDateTime, last : RRuleDateTime) -> Array[Double] raise DateError

    WeekdayLocator::timezone

    WeekdayLocator::unit_scale

    fn WeekdayLocator::unit_scale(self : WeekdayLocator) -> Double

    WeekdayLocator::with_offset

    fn WeekdayLocator::with_offset(self : WeekdayLocator, offset_minutes : Int) -> WeekdayLocator raise DateError

    WeekdayLocator::with_timezone

    fn WeekdayLocator::with_timezone(self : WeekdayLocator, timezone : DateTimeZone) -> WeekdayLocator

    YearLocator

    pub struct YearLocator {
    // private fields
    }

    Matplotlib YearLocator with exact aligned year bounds and a live wrapper. Invalid aligned month/day pairs raise instead of skipping candidate years.

    YearLocator::as_locator

    fn YearLocator::as_locator(self : YearLocator) -> DateLocator

    YearLocator::as_rrule_locator

    fn YearLocator::as_rrule_locator(self : YearLocator) -> RRuleLocator

    Retain yearly bound alignment when adapting to the common locator object.

    YearLocator::base

    fn YearLocator::base(self : YearLocator) -> Int

    YearLocator::interval

    fn YearLocator::interval(self : YearLocator) -> Int

    YearLocator::new

    fn YearLocator::new(base? : Int, month? : Int, day? : Int, tz? : String, timezone? : DateTimeZone, context? : DateParserContext) -> YearLocator raise DateError

    Capture the display zone after constructing the underlying yearly rule. An explicit parser context provides deterministic host-local now fields.

    test {
    let context = @date.DateParserContext::utc(clock=fn() { 1781524800123L })
    let locator = @date.YearLocator::new(
    base=5,
    month=7,
    day=4,
    tz="UTC",
    context~,
    )
    let values = locator.tick_values(
    @date.RRuleDateTime::naive(@date.datetime(2021, 5, 1)),
    @date.RRuleDateTime::naive(@date.datetime(2028, 1, 1)),
    )
    assert_eq(values.map(value => @date.from_ordinal(value).year()), [
    2020, 2025, 2030,
    ])
    }

    YearLocator::rule

    YearLocator::tick_values

    fn YearLocator::tick_values(self : YearLocator, first : RRuleDateTime, last : RRuleDateTime) -> Array[Double] raise DateError

    YearLocator::timezone

    fn YearLocator::timezone(self : YearLocator) -> DateTimeZone

    YearLocator::unit_scale

    fn YearLocator::unit_scale(self : YearLocator) -> Double

    YearLocator::with_offset

    fn YearLocator::with_offset(self : YearLocator, offset_minutes : Int) -> YearLocator raise DateError

    YearLocator::with_timezone

    fn YearLocator::with_timezone(self : YearLocator, timezone : DateTimeZone) -> YearLocator

    auto_date_formatter

    fn auto_date_formatter(lower : Double, upper : Double) -> DateFormatter

    Legacy UTC helper choosing a readable format for a numeric date range.

    auto_date_unit

    fn auto_date_unit(lower : Double, upper : Double, count? : Int) -> Double

    Return the base unit of the frequency chosen by date_tick_values for a view. This shares the generator's selection, rather than inferring unit from ticks.

    business_day_locator

    fn business_day_locator(weekdays? : Array[Int], holidays? : Array[DateTime], interval? : Int, tz? : String, timezone? : DateTimeZone) -> DateLocator raise DateError

    Locate business days using a configurable weekday mask and explicit holiday dates.

    weekdays uses Monday=0 through Sunday=6 and defaults to Monday through Friday. holidays is interpreted as a list of Gregorian calendar dates; the time and fixed offset on each value are ignored. interval advances calendar days before applying the weekday and holiday filters, matching the interval behavior of weekday_locator.

    test {
    let locator = @date.business_day_locator(holidays=[@date.datetime(2024, 1, 1)])
    let ticks = locator.tick_values(
    @date.datetime(2023, 12, 29).to_ordinal(),
    @date.datetime(2024, 1, 5).to_ordinal(),
    )
    assert_eq(@date.format_date_ticks(ticks, format="%Y-%m-%d"), [
    "2023-12-29", "2024-01-02", "2024-01-03", "2024-01-04", "2024-01-05",
    ])
    }

    concise_date_formatter

    fn concise_date_formatter(tz? : String, timezone? : DateTimeZone, formats? : Array[String], zero_formats? : Array[String], offset_formats? : Array[String], show_offset? : Bool, usetex? : Bool) -> ConciseDateFormatter raise DateError

    Construct a concise formatter. tz is resolved when formatting; an omitted tz follows the current timezone rc. The optional format arrays have six entries (years through seconds); empty arrays select defaults. Inputs are copied. usetex returns upstream TeX strings; rendering TeX requires backend support.

    test {
    let formatter = @date.concise_date_formatter()
    let ticks = [
    @date.datetime(2024, 1, 1).to_ordinal(),
    @date.datetime(2024, 1, 2).to_ordinal(),
    ]
    assert_eq(formatter.format_ticks(ticks), ["Jan", "02"])
    assert_eq(formatter.get_offset(), "2024-Jan")
    }

    date2num

    fn date2num(value : DateTime) -> Double

    Matplotlib-compatible name for converting a date to a numeric day value.

    date_formatter

    fn date_formatter(format : String, tz? : String, timezone? : DateTimeZone) -> DateFormatter raise DateError

    Construct a DateFormatter, capturing tz or the current timezone rc. Invalid names raise here. Supply either a string tz or a typed timezone, not both.

    test {
    let formatter = @date.date_formatter("%H:%M %Z", tz="XST-5:45")
    assert_eq(formatter.format_value(0.0), "05:45 XST")
    }

    date_locator

    fn date_locator(interval? : Int, tz? : String, timezone? : DateTimeZone) -> DateLocator raise DateError

    Locate calendar days at a fixed number of day intervals.

    date_parse_warnings

    fn date_parse_warnings() -> Array[DateParseWarning]

    Diagnostics from the last default free-helper operation. Reading them does not construct a parser or access the clock/epoch. Explicit parser instances expose their independent warnings() arrays.

    date_tick_values

    fn date_tick_values(lower : Double, upper : Double, count? : Int, offset_minutes? : Int, timezone? : DateTimeZone) -> Array[Double]

    Generate deterministic date tick values for a numeric day range. A timezone aligns local calendar candidates using exact transition and footer offsets, skipping gaps and retaining both sides of folds.

    datestr2num

    fn datestr2num(text : String, default_date? : DateTime, parser? : DateStringParser) -> Double raise DateError

    Convert a general date string through the fixed default dateutil grammar.

    datestrs2num

    fn datestrs2num(texts : Array[String], default_date? : DateTime, parser? : DateStringParser) -> Array[Double] raise DateError

    Flat-array counterpart of datestr2num. Empty input does not select the host parser or read/lock the numeric epoch.

    datetime

    fn datetime(year : Int, month : Int, day : Int, hour? : Int, minute? : Int, second? : Int, microsecond? : Int, offset_minutes? : Int, offset_seconds? : Int) -> DateTime raise DateError

    Construct a validated Gregorian date and time. offset_seconds selects exact historical offsets. Supply either seconds or a nonzero offset_minutes, never both.

    test {
    let value = @date.datetime(1970, 1, 1, hour=2, offset_minutes=120)
    assert_eq(value.offset_minutes(), 120)
    assert_eq(value.to_ordinal(), 0.0)
    }

    day_locator

    fn day_locator(day? : Int, interval? : Int, bymonthday? : Array[Int], tz? : String, timezone? : DateTimeZone) -> DateLocator raise DateError

    Locate days, optionally using day or a nonempty bymonthday array. Negative selectors count from the end of the month (-1 is the last day). The legacy scalar day=0 selects all days. The interval counts days before filtering, rather than counting occurrences of the selected month days.

    test {
    let locator = @date.day_locator(bymonthday=[1, -1])
    let ticks = locator.tick_values(
    @date.datetime(2024, 2, 1).to_ordinal(),
    @date.datetime(2024, 2, 29).to_ordinal(),
    )
    assert_eq(ticks.map(value => @date.from_ordinal(value).day()), [1, 29])
    }

    default_date_converter

    fn default_date_converter() -> DateConverter

    Dispatch using the current date.converter and date.interval_multiples rc. Already constructed converters and enabled axes retain their snapshots.

    drange

    fn drange(dstart : DateTime, dend : DateTime, delta : TimeDelta) -> Array[Double] raise DateError

    Generate equally spaced numeric dates using Matplotlib's endpoint/linspace algorithm. Endpoints carry their own offsets; a retained rule zone supplies wall-clock duration arithmetic across DST. This retains the upstream endpoint adjustments, including negative steps and floating ceil edge cases. Zero spacing, arithmetic overflow, negative sample counts and counts beyond MoonBit's Int32 array index range raise DateError.

    test {
    let values = @date.drange(
    @date.datetime(2011, 1, 1),
    @date.datetime(2011, 1, 2),
    @date.timedelta(hours=4),
    )
    assert_eq(values.length(), 6)
    assert_eq(@date.num2date(values[5]).hour(), 20)
    }

    fixed_timezone

    fn fixed_timezone(offset_minutes : Int) -> DateTimeZone raise DateError

    Construct a zone with one fixed UTC offset and no transitions.

    fixed_timezone_seconds

    fn fixed_timezone_seconds(offset_seconds : Int) -> DateTimeZone raise DateError

    Construct a fixed zone with an exact seconds offset east of UTC.

    format_date

    fn format_date(value : DateTime, format : String) -> String

    Format standard strftime date/time directives in the deterministic C locale. Week and day fields refer to this value's local calendar. Unknown directives are retained literally; platform flags and arbitrary locales are unsupported.

    test {
    let date = @date.datetime(2021, 1, 1, hour=13)
    assert_eq(
    @date.format_date(date, "%G-W%V-%u %j %I %p"),
    "2020-W53-5 001 01 PM",
    )
    }

    format_date_ticks

    fn format_date_ticks(values : Array[Double], format? : String, offset_minutes? : Int, timezone? : DateTimeZone) -> Array[String]

    Legacy UTC/fixed-offset helper formatting an explicitly supplied tick list. An invalid offset returns an empty list, as with date_tick_values.

    from_ordinal

    fn from_ordinal(value : Double, offset_minutes? : Int, offset_seconds? : Int) -> DateTime raise DateError

    Convert a Matplotlib UTC day value to a date, rounding to the nearest microsecond and applying an optional fixed offset for the returned fields. offset_seconds retains sub-minute history; nonzero offset_minutes and offset_seconds cannot be supplied together.

    get_epoch

    fn get_epoch() -> String

    Select and return the date origin. Reading this value locks the selection.

    get_timezone

    fn get_timezone(name? : String) -> DateTimeZone raise DateError

    Resolve an explicit string, or the current timezone rc when omitted. Exact "UTC" is portable. Other names use registered bytes, host TZif files, then standard POSIX strings. Unavailable/unknown names raise DateError. Construction and resolution do not read the numeric date epoch or clock.

    hour_locator

    fn hour_locator(hour? : Int, interval? : Int, byhour? : Array[Int], tz? : String, timezone? : DateTimeZone) -> DateLocator raise DateError

    Locate hours using hour or a nonempty byhour array (0..23). Omission or the legacy scalar -1 selects all hours; 0 selects midnight. The interval counts hours before filtering.

    test {
    let locator = @date.hour_locator(byhour=[0, 12])
    assert_eq(locator.tick_values(0.0, 1.0), [0.0, 0.5, 1.0])
    }

    hour_locator_at

    fn hour_locator_at(hour : Int, interval? : Int, tz? : String, timezone? : DateTimeZone) -> DateLocator raise DateError

    Locate one explicit hour of each day, including midnight when hour is 0.

    microsecond_locator

    fn microsecond_locator(interval? : Int, tz? : String, timezone? : DateTimeZone) -> DateLocator raise DateError

    Locate ticks at a fixed number of microseconds from the first UTC midnight. Include one adjacent tick beyond each end, as Matplotlib does. Ticks outside years 1..9999 are omitted. Ordinal precision decreases far from 1970.

    test {
    let locator = @date.microsecond_locator(interval=250)
    let ticks = locator.tick_values(
    100.0 / 86_400_000_000.0,
    1000.0 / 86_400_000_000.0,
    )
    assert_eq(ticks.map(value => @date.from_ordinal(value).microsecond()), [
    0, 250, 500, 750, 1000, 1250,
    ])
    }

    minute_locator

    fn minute_locator(minute? : Int, interval? : Int, byminute? : Array[Int], tz? : String, timezone? : DateTimeZone) -> DateLocator raise DateError

    Locate minutes using minute or a nonempty byminute array (0..59). Omission or the legacy scalar -1 selects all minutes; 0 selects minute 0. The interval counts minutes before filtering.

    test {
    let locator = @date.minute_locator(byminute=[0, 30])
    let ticks = locator.tick_values(0.0, 1.0 / 24.0)
    assert_eq(ticks.map(value => @date.from_ordinal(value).minute()), [0, 30, 0])
    }

    minute_locator_at

    fn minute_locator_at(minute : Int, interval? : Int, tz? : String, timezone? : DateTimeZone) -> DateLocator raise DateError

    Locate one explicit minute of each hour, including minute 0.

    month_locator

    fn month_locator(interval? : Int, bymonth? : Array[Int], bymonthday? : Int, tz? : String, timezone? : DateTimeZone) -> DateLocator raise DateError

    Locate months, optionally filtering by bymonth, with day 1 as the default. bymonthday=-1 selects each month's last day. Impossible dates are skipped. The interval counts calendar months before applying the filter.

    test {
    let locator = @date.month_locator(bymonth=[2, 4], bymonthday=-1)
    let ticks = locator.tick_values(
    @date.datetime(2024, 1, 1).to_ordinal(),
    @date.datetime(2024, 5, 1).to_ordinal(),
    )
    assert_eq(
    ticks.map(value => @date.format_date(@date.from_ordinal(value), "%Y-%m-%d")),
    ["2024-02-29", "2024-04-30"],
    )
    }

    month_locator_on

    fn month_locator_on(month : Int, interval? : Int, bymonthday? : Int, tz? : String, timezone? : DateTimeZone) -> DateLocator raise DateError

    Locate one month at a fixed number of calendar month intervals.

    nth_weekday_locator

    fn nth_weekday_locator(weekday? : Int, ordinal? : Int, interval? : Int, bymonth? : Array[Int], byweekday? : Array[Int], tz? : String, timezone? : DateTimeZone) -> DateLocator raise DateError

    Locate the nth occurrence of a weekday in each selected calendar month. ordinal is in -5..-1 or 1..5; negative values count back from the month's end. The interval counts months before applying bymonth. Use byweekday to select more than one weekday; the emitted dates remain in chronological order within each month.

    test {
    let locator = @date.nth_weekday_locator(weekday=0, ordinal=2)
    let ticks = locator.tick_values(
    @date.datetime(2024, 1, 1).to_ordinal(),
    @date.datetime(2024, 4, 30).to_ordinal(),
    )
    assert_eq(
    ticks.map(value => @date.format_date(@date.from_ordinal(value), "%Y-%m-%d")),
    ["2024-01-08", "2024-02-12", "2024-03-11", "2024-04-08"],
    )
    }

    num2date

    fn num2date(value : Double, tz? : String, timezone? : DateTimeZone, offset_minutes? : Int, offset_seconds? : Int) -> DateTime raise DateError

    Convert a numeric UTC day value using the current timezone rc, unless an explicit tz string, timezone object or fixed offset is supplied. Explicit offset_minutes=0 selects UTC. from_ordinal remains the legacy UTC helper.

    num2timedelta

    fn num2timedelta(value : Double) -> TimeDelta raise DateError

    Convert a floating-point day count to a microsecond duration. Fractional microseconds use round-half-to-even, matching datetime.timedelta(days=x). NaN, infinity and durations outside the day range raise DateError.

    test {
    let delta = @date.num2timedelta(1.5)
    assert_eq((delta.days(), delta.seconds()), (1, 43200))
    }

    num2timedeltas

    fn num2timedeltas(values : Array[Double]) -> Array[TimeDelta] raise DateError

    Convert a floating-point day array, preserving order. Invalid elements raise DateError; the input is never modified.

    parse_iso

    fn parse_iso(value : String) -> DateTime raise DateError

    Parse YYYY-MM-DD with an optional T/space-separated HH:MM[:SS[.ffffff]] and fixed UTC offset (Z, +HH, +HHMM[SS], or +HH:MM[:SS]). Fractional seconds contain one to six digits and are padded on the right.

    register_timezone

    fn register_timezone(name : String, data : Bytes) -> Unit raise DateError

    Register supplied TZif bytes for string-based date timezone lookup. This uses dateutil's 32-bit compatibility block, including its historical/future fallback behavior. Use tzif_timezone directly for full 64-bit IANA rules. Registration is explicit and works without host files, including in browsers.

    rrule

    fn rrule(frequency : RRuleFrequency, dtstart : DateTime, interval? : Int, wkst? : Int, bymonth? : Array[Int], bymonthday? : Array[Int], byyearday? : Array[Int], byweekno? : Array[Int], byeaster? : Array[Int], byweekday? : Array[Int], byhour? : Array[Int], byminute? : Array[Int], bysecond? : Array[Int], bysetpos? : Array[Int], count? : Int, until? : DateTime, cache? : Bool) -> RRule raise DateError

    Construct a reusable recurrence rule with an explicit dtstart.

    Keeping the start date required makes object queries deterministic. The locator adapter remains available through RRule::locator when a rule is used to generate axis ticks. Selector arrays are copied, sorted, and deduplicated during construction, so callers can safely reuse or mutate their input arrays afterwards. cache=true shares an incrementally generated occurrence prefix between queries and readers; the default is uncached.

    rrule_locator

    fn rrule_locator(frequency : RRuleFrequency, tz? : String, timezone? : DateTimeZone, interval? : Int, wkst? : Int, bymonth? : Array[Int], bymonthday? : Array[Int], byyearday? : Array[Int], byweekno? : Array[Int], byeaster? : Array[Int], byweekday? : Array[Int], byhour? : Array[Int], byminute? : Array[Int], bysecond? : Array[Int], bysetpos? : Array[Int], dtstart? : DateTime, count? : Int, until? : DateTime) -> DateLocator raise DateError

    Locate dates with a calendar recurrence rule.

    Arrays are copied, sorted and deduplicated; empty or invalid selectors raise DateError. bymonthday counts from either end of the month (-1 is the last day). byweekday and the week start wkst use Monday=0 through Sunday=6. byyearday counts from January 1 (-1 is December 31), byweekno follows the configurable week start, and byeaster selects days relative to Western Easter (zero is Easter Sunday). bysetpos selects positions within each recurrence period after all other filters and expansions, before clipping to the visible range. dtstart supplies the recurrence start used for filtering and counting; when omitted, the locator keeps Matplotlib's visible-window anchor. count limits the number of occurrences from that start, and until is an inclusive date-time bound. Supplying either bound with no explicit dtstart uses the Matplotlib anchor as the start.

    Like Matplotlib's RRuleLocator, the anchor is the lower bound minus the calendar difference between the bounds. Omitted clock fields below the frequency inherit this anchor's fields; recurrence ticks have zero microseconds. With no day selector, yearly/monthly rules inherit its day, yearly rules also inherit its month if omitted, and weekly rules inherit its weekday. Other omitted selectors allow all values.

    The interval advances calendar units before filtering. Use with_offset for a fixed UTC offset; emitted numeric ticks remain UTC day ordinals.

    test {
    let locator = @date.rrule_locator(
    @date.Monthly,
    byweekday=[0, 1, 2, 3, 4],
    bysetpos=[-1],
    byhour=[0],
    byminute=[0],
    bysecond=[0],
    )
    let ticks = locator.tick_values(
    @date.datetime(2024, 1, 1).to_ordinal(),
    @date.datetime(2024, 3, 31).to_ordinal(),
    )
    assert_eq(@date.format_date_ticks(ticks, format="%Y-%m-%d"), [
    "2024-01-31", "2024-02-29", "2024-03-29",
    ])
    }

    rruleset

    fn rruleset(cache? : Bool) -> RRuleSet

    Construct an empty recurrence set. cache=true shares a lazy occurrence prefix across readers and queries. Adding any source invalidates that prefix.

    test {
    let values = @date.rruleset().between(
    @date.datetime(2024, 1, 1),
    @date.datetime(2024, 1, 2),
    inc=true,
    )
    assert_eq(values.length(), 0)
    }

    second_locator

    fn second_locator(second? : Int, interval? : Int, bysecond? : Array[Int], tz? : String, timezone? : DateTimeZone) -> DateLocator raise DateError

    Locate seconds using second or a nonempty bysecond array (0..59). Omission or the legacy scalar -1 selects all seconds; 0 selects second 0. The interval counts seconds before filtering.

    test {
    let locator = @date.second_locator(bysecond=[0, 30])
    let ticks = locator.tick_values(0.0, 1.0 / 1440.0)
    assert_eq(ticks.map(value => @date.from_ordinal(value).second()), [0, 30, 0])
    }

    second_locator_at

    fn second_locator_at(second : Int, interval? : Int, tz? : String, timezone? : DateTimeZone) -> DateLocator raise DateError

    Locate one explicit second of each minute, including second 0.

    set_epoch

    fn set_epoch(value : String) -> Unit raise DateError

    Select a UTC ISO origin before any numeric date conversion/get_epoch call. Supports signed Int32 astronomical years (including 0), partial dates and times through microseconds. Invalid input leaves the selection unchanged; timezone suffixes and finer-than-microsecond precision are not accepted.

    timedelta

    fn timedelta(days? : Int, seconds? : Int64, microseconds? : Int64, milliseconds? : Int64, minutes? : Int, hours? : Int, weeks? : Int) -> TimeDelta raise DateError

    Construct an exact integer-component duration. Components are normalized; seconds and microseconds are nonnegative even when the duration is negative.

    test {
    let delta = @date.timedelta(microseconds=-1L)
    assert_eq(
    (delta.days(), delta.seconds(), delta.microseconds()),
    (-1, 86399, 999999),
    )
    assert_eq(delta.total_seconds(), -0.000001)
    }

    timezone

    fn timezone(initial_offset_minutes : Int, transitions? : Array[TimeZoneTransition]) -> DateTimeZone raise DateError

    Construct a transition-aware date zone.

    test {
    let zone = try! @date.timezone(-300, transitions=[
    try! @date.timezone_transition(@date.datetime(2024, 3, 10, hour=7), -240),
    ])
    let before = try! zone.to_datetime(
    @date.datetime(2024, 3, 10, hour=6, minute=59).to_ordinal(),
    )
    let after = try! zone.to_datetime(
    @date.datetime(2024, 3, 10, hour=7).to_ordinal(),
    )
    assert_eq((before.hour(), before.offset_minutes()), (1, -300))
    assert_eq((after.hour(), after.offset_minutes()), (3, -240))
    }

    timezone_seconds

    fn timezone_seconds(initial_offset_seconds : Int, transitions? : Array[TimeZoneTransition]) -> DateTimeZone raise DateError

    Construct an exact seconds-offset transition zone.

    test {
    let zone = @date.timezone_seconds(561, transitions=[
    @date.timezone_transition_seconds(@date.datetime(1911, 3, 11), 0),
    ])
    assert_eq(
    zone.offset_seconds_at(@date.datetime(1900, 1, 1).to_ordinal()),
    561,
    )
    }

    timezone_transition

    fn timezone_transition(at : DateTime, offset_minutes : Int) -> TimeZoneTransition raise DateError

    Construct a transition at the instant represented by at.

    The local fields and offset on at are converted to an instant first, so callers may pass either a UTC value or a value carrying another fixed offset.

    timezone_transition_seconds

    fn timezone_transition_seconds(at : DateTime, offset_seconds : Int) -> TimeZoneTransition raise DateError

    Construct a transition using an exact seconds offset east of UTC.

    tzif_timezone

    fn tzif_timezone(data : Bytes) -> DateTimeZone raise DateError

    Load caller-supplied TZif v2/v3 data into a transition-aware date zone.

    unregister_timezone

    fn unregister_timezone(name : String) -> Unit

    Remove an explicit TZif registration. Previously constructed consumers keep their captured rules; subsequent name lookups resume normal host resolution.

    weekday_locator

    fn weekday_locator(weekday? : Int, interval? : Int, byweekday? : Array[Int], tz? : String, timezone? : DateTimeZone) -> DateLocator raise DateError

    Locate weekdays using Monday=0 through Sunday=6; the default is Tuesday. Use either weekday or a nonempty byweekday array. As in Matplotlib, interval counts days before filtering by weekday.

    test {
    let locator = @date.weekday_locator(byweekday=[0, 2])
    let ticks = locator.tick_values(
    @date.datetime(2024, 1, 1).to_ordinal(),
    @date.datetime(2024, 1, 7).to_ordinal(),
    )
    assert_eq(ticks.map(value => @date.from_ordinal(value).day()), [1, 3])
    }

    year_locator

    fn year_locator(base? : Int, month? : Int, day? : Int, tz? : String, timezone? : DateTimeZone) -> DateLocator raise DateError

    Locate a given month and day every base years, including aligned years outside the visible range. Invalid dates in non-leap years are skipped.