Skip to content

Archmage.DateTime

A point in time with the UTC offset it was written with, the type of a datetime field.

Inherits: RefCounted

In the config files, a datetime is an RFC 3339 string, such as 2025-01-01T08:30:00+08:00, or null when it is zero. The zero value is the instant 0001-01-01T00:00:00Z, as in Go.

const ZERO_UNIX_TIME = -62135596800

The Unix time of the instant at 0001-01-01T00:00:00Z.

var unix_time: int = -62135596800

The seconds since 1970-01-01T00:00:00Z, the value that Time.get_unix_time_from_system() returns.

var nanosecond: int

The nanoseconds within the second, from 0 to 999999999.

var offset: int

The UTC offset in seconds, such as 28800 for +08:00. to_json() writes the time with this offset.

func is_zero() -> bool

Returns whether this is the zero value. An instant is zero regardless of its offset.

static func from_json(v: Variant, e: Archmage.ParseError = null) -> Archmage.DateTime

Returns the datetime in v, a parsed JSON value. For null, returns the zero value. For any other value that is not an RFC 3339 string, records the error in e (see Archmage.ParseError.report()) and returns the zero value.

func to_json() -> Variant

Returns the datetime as an RFC 3339 string with offset, or null for the zero value. The fraction of a second is written only when it is not zero, and the offset 0 is written as Z.