startOrEndOfUtc
Signature
Section titled “Signature”startOrEndOfUtc(value: string, unit: any, options: { weekStartsOn?: "monday" | "sunday"; fractionalSecondDigits?: FractionalDigit; }, isEnd: boolean): stringimport { startOrEndOfUtc } from "@northguild/gmt/utc/calculate";Internal shared implementation for startOfUtc / endOfUtc.
- Converts the UTC Instant to a ZonedDateTime, snaps to the start or end of the requested unit, then converts back to an Instant string.
- Supports every Temporal
DateUnitandTimeUnit. weekStartsOnshifts the week boundary:"monday"(default) or"sunday".fractionalSecondDigitsoverrides the default sub-second precision for the returned Instant string; defaults to 3 for millisecond, 6 for microsecond, 9 for nanosecond, and 0 for all coarser units.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
value |
string |
ISO UTC datetime string |
unit |
any |
Temporal.DateUnit | Temporal.TimeUnit to snap to |
isEnd |
boolean |
false for start-of-unit, true for end-of-unit |
Options
Section titled “Options”options
| Option | Type | Default |
|---|---|---|
weekStartsOn? |
"monday" | "sunday" |
— |
fractionalSecondDigits? |
FractionalDigit |
— |
Returns
Section titled “Returns”UTC Instant string, or “” on invalid input