getZonedNowUnit
Signature
Section titled “Signature”getZonedNowUnit(ianaTimezone: string, unit: ZonedNowUnit): stringReturn the requested current unit value for the specified IANA timeZone.
- Uses Temporal.Now.zonedDateTimeISO to get the current time.
weekis the ISO 8601 week number, fromparseWeekFromDate.- Validation is performed on timezone and unit.
unitaccepts the singular or plural name of a Temporal unit ("hour"or"hours"), as Temporal does;"dayOfWeek"has no plural.- The
"year"unit is written as Temporal writes a year: four digits ("2024","0005"), or a sign and six digits outside 0000–9999 ("+010000","-000005").
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
ianaTimezone | string | IANA name or UTC offset: a time zone identifier (+05:30, +0530, -08) or a stored offset (±HH:MM[:SS], what getTimeZoneOffset returns) |
unit | ZonedNowUnit | unit to extract from current zoned time |
Returns
Section titled “Returns”string representation of the requested unit or "" on invalid input
ZonedNowUnit
Section titled “ZonedNowUnit”Units extractable from the current time in a specific IANA timeZone, as consumed by getZonedNowUnit.
import type { ZonedNowUnit } from "@northguild/gmt";"dayOfWeek" | SmallestUnit<"year" | "month" | "week" | "day" | "hour" | "minute" | "second" | "millisecond" | "microsecond" | "nanosecond">Examples
Section titled “Examples”import { getZonedNowUnit } from "@northguild/gmt/zoned/get";
getZonedNowUnit("America/New_York", "hour") // "07"