Skip to main content

Function: zonedWallTimeToUtc()

zonedWallTimeToUtc(dateISO, timeHHMM, timeZone): Date

Defined in: src/lib/dates/tz.ts:125

The UTC instant for a wall-clock time (HH:MM) on a business day (YYYY-MM-DD) in timeZone. Used to store a manual from–to pair's started_at/ended_at. (DST-transition wall times that don't exist/repeat resolve to a single nearby instant — acceptable for hour logging.)

Inverse of businessDayInTz + formatTimeInTz: takes a date and time as the user sees them on the local clock and returns the corresponding absolute UTC Date for storage. The offset is taken at the wall time itself (DST-aware), so the same HH:MM on a summer vs winter day yields the correct distinct UTC instants.

Parameters​

dateISO​

string

The local calendar day as YYYY-MM-DD (as produced by businessDayInTz).

timeHHMM​

string

The local wall-clock time as 24-hour HH:MM (as produced by formatTimeInTz).

timeZone​

string

IANA timezone identifier the wall time is expressed in (e.g. America/New_York).

Returns​

Date

A Date representing the absolute UTC instant. Store UTC; render via the tz helpers.

Throws​

RangeError If dateISO/timeHHMM do not form a valid YYYY-MM-DDTHH:MM instant, or if timeZone is invalid.

Example​

// 09:00 on 2026-06-21 in New York (EDT, UTC−4) → 13:00Z
zonedWallTimeToUtc('2026-06-21', '09:00', 'America/New_York');