Esc

to_timestamp

procedureextensionsince 0.36.1Source
  • macOS: to_timestamp works on macOS
  • Linux: to_timestamp works on Linux
  • Windows: to_timestamp works on Windows
  • Wasm: to_timestamp works on Wasm

Resolves gaps/folds using the requested policy and checks UTC range.

Signature

to_timestamp :: (
    zone: Time_Zone,
    wall: Date_Time,
    disambiguation := Disambiguation.COMPATIBLE
) -> (Timestamp, Time_Error)
Example↗
zone, zone_error := time_zone_from_posix("EST5EDT,M3.2.0,M11.1.0");
assert(zone_error.kind == .NONE);
defer time_zone_free(*zone);
gap := Date_Time.{ .{ 2024, 3, 10 }, .{ 2, 30, 0, 0 } };
instant, error := to_timestamp(zone, gap);
assert(error.kind == .NONE && instant.seconds == 1710055800);
_, rejected := to_timestamp(zone, gap, .REJECT);
assert(rejected.kind == .GAP);

See also