mapZonedHoursInDay
Signature
Section titled “Signature”mapZonedHoursInDay(anchor: string): string[]Return an array of zoned datetime strings representing each hour boundary of the anchor’s local day.
- Steps hourly from the day’s
startOfDay()up to (not including) the next day’sstartOfDay(), so the result always stays on the anchor’s date. A day whose local midnight is skipped (e.g.America/Santiagoon 2024-09-08) starts at 01:00 and has 23 entries. - Handles DST transitions: hourly steps are exact elapsed hours, so a spring-forward day has 23 entries and a fall-back day 25.
- In zones with a 30-minute shift (
Australia/Lord_Howe), entries after the transition land on :30 — hourly steps are exact elapsed hours, not wall-clock hour marks (2024-10-06 gives00:00,01:00,02:30, …23:30). - The day is the anchor’s calendar date, as TC39’s
startOfDay()/hoursInDaydefine it. This differs fromstartOfZoned(…, "day")only where a fall-back re-enters the previous date:America/Goose_Bayfell back at 00:01 on 2010-11-07, so an anchor at2010-11-06T23:30:00-04:00maps 6 November’s 24 hours (ending at 00:00-03:00 on the 7th, before the anchor), whilestartOfZonedputs that anchor in a reopened 59-minute day. - Takes no options: the day’s window is always real instants, as TC39’s
startOfDay()gives. The ignoreddisambiguation/offsetoptions argument was removed in 1.16.0. - Returns [] for invalid input.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
anchor | string | zoned ISO 8601 datetime string used as anchor |
Returns
Section titled “Returns”array of zoned ISO 8601 strings for each hour in the day
Examples
Section titled “Examples”import { mapZonedHoursInDay } from "@northguild/gmt/zoned/map";
mapZonedHoursInDay("2024-02-29T12:34:56.789+00:00[UTC]") // ["2024-02-29T00:00:00+00:00[UTC]", "2024-02-29T01:00:00+00:00[UTC]", ..., "2024-02-29T23:00:00+00:00[UTC]"]