getNowUnit
Signature
Section titled “Signature”getNowUnit(unit: NowUnit): stringReturn the requested current unit value using the system timeZone.
- Valid units: “year”, “month”, “week”, “day”, “dayOfWeek”, “hour”, “minute”, “second”, “millisecond”, “microsecond”, “nanosecond”.
- Uses Temporal.Now.zonedDateTimeISO to get current time in system timezone.
unitaccepts the singular or plural name of a Temporal unit ("hour"or"hours"), as Temporal does;"dayOfWeek"has no plural.- Returns "" when unit is invalid or system timezone is unavailable.
- 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 |
|---|---|---|
unit | NowUnit | unit to extract from current local time |
Returns
Section titled “Returns”string representation of the requested unit or "" on invalid
NowUnit
Section titled “NowUnit”Units extractable from the current system local time via getNowUnit. Defined as DateTimeUnit | "dayOfWeek".
import type { NowUnit } from "@northguild/gmt";SmallestUnit<DateTimeUnit> | "dayOfWeek"Examples
Section titled “Examples”import { getNowUnit } from "@northguild/gmt/plain/get";
getNowUnit("year") // "2024"