Esc

start_of_day

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

Finds the first valid instant of the local date, including days starting after midnight.

Signature

start_of_day :: (value: Zoned) -> (Zoned, 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);
noon, _ := to_zoned(.{ .{ 2024, 3, 10 }, .{ 15, 0, 0, 0 } }, zone);
start, error := start_of_day(noon);
assert(error.kind == .NONE && to_civil(zone, start.timestamp).time.hour == 0);

See also