Module Temporal.DateTime

type t = datetime

A point in time (see datetime).

val of_epoch_seconds : ?tz:tz -> int64 -> int -> t

A datetime from UTC epoch seconds and sub-second nanoseconds.

val to_epoch_seconds : t -> int64 * int

The (epoch seconds, nanoseconds) of a datetime.

val tz : t -> tz option

The time zone, if any.

val of_ymd_hms : ?tz:tz -> (int * int * int) -> (int * int * int) -> int -> t option

A datetime from a wall clock and optional time zone. Named zones are resolved through the IANA time zone database embedded in Timedesc; None for unknown zones or out-of-range values.

val to_ymd_hms : t -> (int * int * int) * (int * int * int) * int

The wall clock ((y, m, d), (h, m, s), nanoseconds) in the datetime's zone. For named zones the offset at the instant is resolved from the embedded IANA database.

val offset_seconds : t -> int option

The UTC offset in seconds at the datetime's instant: the fixed offset for Offset zones, resolved from the embedded IANA database for Zone_name zones (None if the zone is unknown).

val add : Duration.t -> t -> t option

Add a duration; None for named zones.

val sub : Duration.t -> t -> t option

Subtract a duration; None for named zones.

val diff : t -> t -> Duration.t option

Difference a - b as a duration; None if either has a named zone.

val compare : t -> t -> int

Compare two datetimes by their instant.

val equal : t -> t -> bool

Whether two datetimes are the same instant.

val to_iso8601 : t -> string

Format as "YYYY-MM-DDTHH:MM:SS.fff...+HH:MM".

val of_iso8601 : string -> t option

Parse an ISO 8601 datetime; None if invalid or the zone is named.

val to_ptime : t -> Ptime.t option

Convert to a Ptime.t; None for named zones.

val of_ptime : ?tz:tz -> Ptime.t -> t

A datetime from a Ptime.t (UTC).

val to_string : t -> string

Alias for to_iso8601.