Skip to content

getZonedNowUnit

getZonedNowUnit(ianaTimezone: string, unit: ZonedNowUnit): string
import { getZonedNowUnit } from "@northguild/gmt/zoned/get";

Return the requested current unit value for the specified IANA timeZone.

  • Uses Temporal.Now.zonedDateTimeISO to get the current time.
  • Uses weekOfYear helper for week calculations.
  • Validation is performed on timezone and unit.
Parameter Type Description
ianaTimezone string IANA timeZone identifier
unit ZonedNowUnit unit to extract from current zoned time

string representation of the requested unit or “” on invalid input

getZonedNowUnit("America/New_York", "hour") // "07"
getZonedNowUnit("invalid", "hour") // ""

zoned/get/getZonedNowUnit.ts