Skip to main content

Function: businessDayInTz()

businessDayInTz(instant, timeZone): string

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

The business day (YYYY-MM-DD) that instant falls on in timeZone.

Resolves the calendar date for a UTC instant as observed at the wall clock of the given timezone (e.g. the assigned facility's). Because the date is timezone-relative, an instant near midnight UTC can map to a different day depending on timeZone — this is the intended boundary where a UTC instant becomes a business day for hour-logging / payroll bucketing.

Parameters

instant

Date

The absolute point in time (a UTC-based Date) to bucket.

timeZone

string

IANA timezone identifier (e.g. America/New_York); invalid ids throw RangeError.

Returns

string

The local calendar date in strict YYYY-MM-DD format (zero-padded), via en-CA.

Throws

RangeError If timeZone is not a valid IANA timezone identifier.

Throws

RangeError If instant is an invalid Date (Invalid time value).