automata/schedule/ast

Public runtime types for the unified schedule API: Date, Time, DateTime, ValidDateTime, Weekday, Boundary, and the smart constructors / stringifiers that every cron / RRULE / iCal / schedule caller needs to build the anchor and after arguments. The parse / validate / iterate entry points live in automata/schedule and the feature-specific modules (automata/cron, automata/rrule, automata/ical). Despite the ast suffix, these are the runtime domain types, not parser internals.

Types

Boundary semantics used when starting iteration.

Both variants wrap ValidDateTime so iterators can never be started from an impossible date such as 2026-02-30.

pub type Boundary {
  Inclusive(ValidDateTime)
  Exclusive(ValidDateTime)
}

Constructors

Calendar date in the proleptic Gregorian calendar.

pub type Date {
  Date(year: Int, month: Int, day: Int)
}

Constructors

  • Date(year: Int, month: Int, day: Int)

Naive date-time used by schedule matching and iteration.

pub type DateTime {
  DateTime(date: Date, time: Time)
}

Constructors

Errors that can occur when smart-constructing DateTime values.

pub type DateTimeError {
  InvalidDate(year: Int, month: Int, day: Int)
  InvalidTime(hour: Int, minute: Int, second: Int)
}

Constructors

  • InvalidDate(year: Int, month: Int, day: Int)
  • InvalidTime(hour: Int, minute: Int, second: Int)

Wall-clock time with second precision.

pub type Time {
  Time(hour: Int, minute: Int, second: Int)
}

Constructors

  • Time(hour: Int, minute: Int, second: Int)

A DateTime proven to fall in the valid Gregorian range.

Construct via try_datetime/6; unwrap with valid_datetime_value/1.

pub opaque type ValidDateTime

Gregorian weekday names shared by cron and RRULE APIs.

pub type Weekday {
  Monday
  Tuesday
  Wednesday
  Thursday
  Friday
  Saturday
  Sunday
}

Constructors

  • Monday
  • Tuesday
  • Wednesday
  • Thursday
  • Friday
  • Saturday
  • Sunday

Values

pub fn date(
  year year: Int,
  month month: Int,
  day day: Int,
) -> Date
pub fn datetime(
  year year: Int,
  month month: Int,
  day day: Int,
  hour hour: Int,
  minute minute: Int,
  second second: Int,
) -> DateTime
pub fn time(
  hour hour: Int,
  minute minute: Int,
  second second: Int,
) -> Time
pub fn to_string(datetime: DateTime) -> String
pub fn try_datetime(
  year year: Int,
  month month: Int,
  day day: Int,
  hour hour: Int,
  minute minute: Int,
  second second: Int,
) -> Result(DateTime, DateTimeError)

Build a validated DateTime from raw integer components.

Returns Error(InvalidDate) for impossible calendar dates such as February 30, and Error(InvalidTime) for clock components outside 00:00:00-23:59:59.

pub fn try_valid_datetime(
  year year: Int,
  month month: Int,
  day day: Int,
  hour hour: Int,
  minute minute: Int,
  second second: Int,
) -> Result(ValidDateTime, DateTimeError)

Build an opaque ValidDateTime, propagating validation errors.

pub fn valid_datetime_value(valid: ValidDateTime) -> DateTime

Recover the raw DateTime value from a ValidDateTime.

pub fn weekday_to_string(weekday: Weekday) -> String
Search Document