README

#Moonbit/Core Time for MORM

#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~) catch {
_ => fail("expected unix time to parse")
}
inspect(
date_time.to_string(),
content="2024-04-27T22:22:09.000001+08:00[Asia/Shanghai]",
)
}

#
Duration

type Duration derive(Compare, Eq)

An amount of time with nanosecond precision.
impl Show 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::from_string

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

type Period derive(Compare, Eq)

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

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

Returns the number of days in this duration.

#
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::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_sub

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

#
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

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

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

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

Creates a PlainDate from the year, month and day.

#
PlainDate::ordinal

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

Returns the ordinal day of the year.

#
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

type PlainDateTime derive(Compare, Eq)

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

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

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

Returns the ordinal day of year of this datetime.

#
PlainDateTime::second

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

Returns the second of this datetime.

#
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_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

type PlainTime derive(Compare, Eq)

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

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::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::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_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)

impl Show for Weekday

#
Zone

type Zone derive(Eq)

Time zone.
impl Show for Zone

#
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::to_string

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

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

#
ZoneOffset

type ZoneOffset

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

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

Returns the total seconds of this offset.

#
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

A datetime with a time zone and offset in the ISO 8601 calendar system.
impl Eq for ZonedDateTime

#
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_string

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

#
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::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_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.