Esc

time_zone_from_tzif

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

Copies validated TZif v1-v4 rules and POSIX footer within bounded storage.

Signature

time_zone_from_tzif :: (
    name: string,
    bytes: [] u8,
    options: Time_Options = .{}
) -> (Time_Zone, Time_Error)
Example↗
bytes := u8.[
    0x54, 0x5a, 0x69, 0x66, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 4,
    0, 0, 0x1c, 0x20, 0, 0, 0x4d, 0x59, 0x54, 0, // one type: +02:00 "MYT"
];
zone, error := time_zone_from_tzif("Example/Zone", bytes);
assert(error.kind == .NONE);
defer time_zone_free(*zone);
instant, _ := timestamp_from_seconds(0);
assert(offset_at(zone, instant).seconds == 7200);

See also