#Moonbit/Core Time

    #Overview

    Package time provides functionality for measuring and manipulating time.

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

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

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

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

    #TODOs

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

    Duration

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

    Duration::add_duration

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

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

    Duration::add_hours

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

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

    Duration::add_minutes

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

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

    Duration::add_nanoseconds

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

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

    Duration::add_seconds

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

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

    Duration::compare

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

    Duration::equal

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

    Duration::from_str

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

    Duration::from_string

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

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

    Duration::is_neg

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

    Checks if this duration is negative.

    Duration::is_zero

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

    Checks if this duration is zero length.

    Duration::nanoseconds

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

    Returns the number of nanoseconds in this duration.

    Duration::not_equal

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

    Duration::of

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

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

    Duration::op_add

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

    Duration::op_ge

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

    Duration::op_gt

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

    Duration::op_le

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

    Duration::op_lt

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

    Duration::output

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

    Duration::seconds

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

    Returns the number of seconds in this duration.

    Duration::to_nanoseconds

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

    Converts this duration to the total length in nanoseconds.

    Duration::to_repr

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

    Duration::to_string

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

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

    Duration::with_nanoseconds

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

    Returns a new duration with the specified nanosecond of second.

    Duration::with_seconds

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

    Returns a new duration with the specified amount of seconds.

    Duration::zero

    fn Duration::zero() -> Duration

    Returns a zero length duration.

    Period

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

    Period::add_days

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

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

    Period::add_months

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

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

    Period::add_period

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

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

    Period::add_weeks

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

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

    Period::add_years

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

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

    Period::compare

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

    Period::days

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

    Returns the number of days in this duration.

    Period::equal

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

    Period::from_string

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

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

    Period::is_neg

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

    Checks if this period is negative.

    Period::is_zero

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

    Checks if this period is zero length.

    Period::months

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

    Returns the number of months in this duration.

    Period::multiply

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

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

    Period::negated

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

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

    Period::not_equal

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

    Period::of

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

    Creates a Period from years, months, and days.

    Period::op_add

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

    Period::op_ge

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

    Period::op_gt

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

    Period::op_le

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

    Period::op_lt

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

    Period::op_sub

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

    Period::output

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

    Period::to_repr

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

    Period::to_string

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

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

    Period::to_total_months

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

    Returns the total number of months in this period.

    Period::with_days

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

    Returns a new period with the specified amount of days.

    Period::with_months

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

    Returns a new period with the specified amount of months.

    Period::with_years

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

    Returns a new period with the specified amount of years.

    Period::years

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

    Returns the number of years in this duration.

    Period::zero

    fn Period::zero() -> Period

    Returns a zero length period.

    PlainDate

    type PlainDate derive(
    Debug
    )

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

    PlainDate::add_days

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

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

    PlainDate::add_months

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

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

    PlainDate::add_period

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

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

    PlainDate::add_weeks

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

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

    PlainDate::add_years

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

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

    PlainDate::compare

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

    PlainDate::day

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

    Returns the day of the month.

    PlainDate::days_in_month

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

    Returns the number of days in the month.

    PlainDate::days_in_week

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

    Returns the number of days in the week.

    PlainDate::days_in_year

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

    Returns the number of days in the year.

    PlainDate::equal

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

    PlainDate::era

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

    Returns the era of this date.

    PlainDate::era_year

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

    Returns the year of the era of this date.

    PlainDate::from_json

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

    PlainDate::from_str

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

    PlainDate::from_string

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

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

    PlainDate::from_unix_day

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

    Creates a date from the days count since unix epoch.

    PlainDate::from_year_ord

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

    Creates a PlainDate from year and ordinal day.

    PlainDate::in_leap_year

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

    Checks if the date is in a leap year.

    PlainDate::month

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

    Returns the ordinal number of month in the current year.

    PlainDate::months_in_year

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

    Returns the number of months in the year.

    PlainDate::not_equal

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

    PlainDate::of

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

    Creates a PlainDate from the year, month and day.

    PlainDate::op_ge

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

    PlainDate::op_gt

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

    PlainDate::op_le

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

    PlainDate::op_lt

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

    PlainDate::ordinal

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

    Returns the ordinal day of the year.

    PlainDate::output

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

    PlainDate::to_json

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

    PlainDate::to_repr

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

    PlainDate::to_string

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

    Returns a string representing the date.

    PlainDate::to_unix_day

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

    Returns the days count since unix epoch of this date.

    PlainDate::until

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

    Returns the period between this date and another date.

    PlainDate::weekday

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

    Returns the weekday.

    PlainDate::with_day

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

    Returns a new date with the specified day of month.

    PlainDate::with_month

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

    Returns a new date with the specified month.

    PlainDate::with_ordinal

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

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

    PlainDate::with_year

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

    Returns a new date with the specified year.

    PlainDate::year

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

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

    PlainDateTime

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

    PlainDateTime::add_days

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

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

    PlainDateTime::add_duration

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

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

    PlainDateTime::add_hours

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

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

    PlainDateTime::add_minutes

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

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

    PlainDateTime::add_months

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

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

    PlainDateTime::add_nanoseconds

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

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

    PlainDateTime::add_period

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

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

    PlainDateTime::add_seconds

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

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

    PlainDateTime::add_weeks

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

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

    PlainDateTime::add_years

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

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

    PlainDateTime::compare

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

    PlainDateTime::day

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

    Returns the day of month of this datetime.

    PlainDateTime::days_in_month

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

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

    PlainDateTime::days_in_week

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

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

    PlainDateTime::days_in_year

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

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

    PlainDateTime::equal

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

    PlainDateTime::era

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

    Returns the era of this datetime.

    PlainDateTime::era_year

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

    Returns the year of era of this datetime.

    PlainDateTime::from_json

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

    PlainDateTime::from_str

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

    PlainDateTime::from_string

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

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

    PlainDateTime::from_unix_second

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

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

    PlainDateTime::hour

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

    Returns the hour of this datetime.

    PlainDateTime::in_leap_year

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

    Checks if this datetime is in a leap year.

    PlainDateTime::minute

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

    Returns the minute of this datetime.

    PlainDateTime::month

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

    Returns the month of this datetime.

    PlainDateTime::months_in_year

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

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

    PlainDateTime::nanosecond

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

    Returns the nanosecond of this datetime.

    PlainDateTime::not_equal

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

    PlainDateTime::of

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

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

    PlainDateTime::op_ge

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

    PlainDateTime::op_gt

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

    PlainDateTime::op_le

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

    PlainDateTime::op_lt

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

    PlainDateTime::ordinal

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

    Returns the ordinal day of year of this datetime.

    PlainDateTime::output

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

    PlainDateTime::second

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

    Returns the second of this datetime.

    PlainDateTime::to_json

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

    PlainDateTime::to_plain_date

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

    Returns the date part of this datetime.

    PlainDateTime::to_plain_time

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

    Returns the time part of this datetime.

    PlainDateTime::to_repr

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

    PlainDateTime::to_string

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

    Returns a string representing the datetime.

    PlainDateTime::to_unix_second

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

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

    PlainDateTime::weekday

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

    Returns the weekday of this datetime.

    PlainDateTime::with_day

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

    Returns a new datetime with the specified day of month.

    PlainDateTime::with_hour

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

    Returns a new datetime with the specified hour.

    PlainDateTime::with_minute

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

    Returns a new datetime with the specified minute.

    PlainDateTime::with_month

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

    Returns a new datetime with the specified month.

    PlainDateTime::with_nanosecond

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

    Returns a new datetime with the specified nanosecond.

    PlainDateTime::with_ordinal

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

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

    PlainDateTime::with_second

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

    Returns a new datetime with the specified second.

    PlainDateTime::with_year

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

    Returns a new datetime with the specified year.

    PlainDateTime::year

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

    Returns the year of this datetime.

    PlainTime

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

    PlainTime::add_duration

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

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

    PlainTime::add_hours

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

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

    PlainTime::add_minutes

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

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

    PlainTime::add_nanoseconds

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

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

    PlainTime::add_seconds

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

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

    PlainTime::at_date

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

    Combines this time with a date to creates a PlainDateTime

    PlainTime::compare

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

    PlainTime::equal

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

    PlainTime::from_json

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

    PlainTime::from_nanosecond_of_day

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

    Creates a PlainTime from the total nanoseconds of the day.

    PlainTime::from_second_of_day

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

    Creates a PlainTime from the total seconds of the day.

    PlainTime::from_str

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

    PlainTime::from_string

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

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

    PlainTime::hour

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

    Returns the hour of this time.

    PlainTime::minute

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

    Returns the minute of this time.

    PlainTime::nanosecond

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

    Returns the nanosecond of this time.

    PlainTime::nanosecond_of_day

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

    Returns the total nanoseconds of this time.

    PlainTime::not_equal

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

    PlainTime::of

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

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

    PlainTime::op_ge

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

    PlainTime::op_gt

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

    PlainTime::op_le

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

    PlainTime::op_lt

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

    PlainTime::output

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

    PlainTime::second

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

    Returns the second of this time.

    PlainTime::second_of_day

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

    Returns the total seconds of this time.

    PlainTime::to_json

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

    PlainTime::to_repr

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

    PlainTime::to_string

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

    Returns a string representing the time.

    PlainTime::until

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

    Returns the duration between this time and another time.

    PlainTime::with_hour

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

    Returns a new time with the specified hour.

    PlainTime::with_minute

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

    Returns a new time with the specified minute.

    PlainTime::with_nanosecond

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

    Returns a new time with the specified nanosecond.

    PlainTime::with_second

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

    Returns a new time with the specified second.

    Weekday

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

    impl Show for Weekday

    Weekday::equal

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

    Weekday::not_equal

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

    Weekday::output

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

    Weekday::to_repr

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

    Weekday::to_string

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

    Zone

    Time zone.
    impl Show for Zone

    Zone::equal

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

    Zone::from_tzif2

    fn Zone::from_tzif2(id : String, data : FixedArray[Byte]) -> Zone raise

    Creates a time zone from TZif2 data.

    Zone::is_fixed

    fn Zone::is_fixed(self : Zone) -> Bool

    Checks if this zone only has one offset.

    Zone::not_equal

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

    Zone::output

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

    Zone::to_repr

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

    Zone::to_string

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

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

    ZoneOffset

    type ZoneOffset derive(
    Debug
    )

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

    ZoneOffset::abbreviation

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

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

    ZoneOffset::compare

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

    ZoneOffset::equal

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

    ZoneOffset::from_seconds

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

    Creates a offset from seconds.

    ZoneOffset::id

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

    Returns the offset id.

    ZoneOffset::is_dst

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

    Checks if this offset is daylight saving time.

    ZoneOffset::not_equal

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

    ZoneOffset::of

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

    Creates a offset from hours, minutes and seconds.

    ZoneOffset::op_ge

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

    ZoneOffset::op_gt

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

    ZoneOffset::op_le

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

    ZoneOffset::op_lt

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

    ZoneOffset::output

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

    ZoneOffset::seconds

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

    Returns the total seconds of this offset.

    ZoneOffset::to_repr

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

    ZoneOffset::to_string

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

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

    ZonedDateTime

    type ZonedDateTime derive(
    Debug
    )

    A datetime with a time zone and offset in the ISO 8601 calendar system.

    ZonedDateTime::add_days

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

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

    ZonedDateTime::add_hours

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

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

    ZonedDateTime::add_minutes

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

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

    ZonedDateTime::add_months

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

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

    ZonedDateTime::add_nanoseconds

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

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

    ZonedDateTime::add_seconds

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

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

    ZonedDateTime::add_weeks

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

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

    ZonedDateTime::add_years

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

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

    ZonedDateTime::day

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

    Returns the day of month of this datetime.

    ZonedDateTime::days_in_month

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

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

    ZonedDateTime::days_in_week

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

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

    ZonedDateTime::days_in_year

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

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

    ZonedDateTime::era

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

    Returns the era of this datetime.

    ZonedDateTime::era_year

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

    Returns the year of era of this datetime.

    ZonedDateTime::from_plain_datetime

    fn ZonedDateTime::from_plain_datetime(datetime : PlainDateTime, zone? : Zone) -> ZonedDateTime

    Creates a ZonedDateTime from a PlainDateTime and a time zone. The default time zone is UTC+0.

    ZonedDateTime::from_unix_second

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

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

    ZonedDateTime::hour

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

    Returns the hour of this datetime.

    ZonedDateTime::in_leap_year

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

    Checks if this datetime is in a leap year.

    ZonedDateTime::minute

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

    Returns the minute of this datetime.

    ZonedDateTime::month

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

    Returns the month of this datetime.

    ZonedDateTime::months_in_year

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

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

    ZonedDateTime::nanosecond

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

    Returns the nanosecond of this datetime.

    ZonedDateTime::of

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

    Creates a ZonedDateTime from year, month, day, hour, minute and second. The default time zone is UTC+0.

    ZonedDateTime::offset

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

    Returns the time offset of this datetime.

    ZonedDateTime::ordinal

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

    Returns the ordinal day of year of this datetime.

    ZonedDateTime::output

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

    ZonedDateTime::second

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

    Returns the second of this datetime.

    ZonedDateTime::to_plain_date

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

    Returns the date part of this datetime, without timezone.

    ZonedDateTime::to_plain_date_time

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

    Returns the datetime part of this datetime, without timezone.

    ZonedDateTime::to_plain_time

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

    Returns the time part of this datetime, without timezone.

    ZonedDateTime::to_repr

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

    ZonedDateTime::to_string

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

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

    ZonedDateTime::to_unix_second

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

    Returns the elapsed seconds since the unix epoch.

    ZonedDateTime::weekday

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

    Returns the weekday of this datetime.

    ZonedDateTime::with_day

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

    Returns a new datetime with the specified day of the month.

    ZonedDateTime::with_hour

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

    Returns a new datetime with the specified hour.

    ZonedDateTime::with_minute

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

    Returns a new datetime with the specified minute.

    ZonedDateTime::with_month

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

    Returns a new datetime with the specified month.

    ZonedDateTime::with_nanosecond

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

    Returns a new datetime with the specified nanosecond.

    ZonedDateTime::with_ordinal

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

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

    ZonedDateTime::with_second

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

    Returns a new datetime with the specified second.

    ZonedDateTime::with_year

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

    Returns a new datetime with the specified year.

    ZonedDateTime::year

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

    Returns the year of this datetime.

    ZonedDateTime::zone

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

    Returns the time zone of this datetime.

    date_time

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

    Creates a ZonedDateTime from year, month, day, hour, minute, second and a time zone. The default time zone is UTC+0.

    fixed_zone

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

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

    unix

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

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

    utc_offset

    let utc_offset : ZoneOffset

    UTC+0 offset.

    utc_zone

    let utc_zone : Zone

    UTC time zone.