endOfTime
Signature
Section titled “Signature”endOfTime(value: string, unit: EndOfTimeUnit, optionsArg?: { fractionalSecondDigits?: FractionalDigit; }): stringReturn the end of the specified time unit for a given ISO 8601 time string.
unitaccepts the singular or plural name ("hour"or"hours"), as Temporal does.- Returns "" for invalid inputs.
- Compatibility: before 1.16.0 the default printed only the digits the unit names — none for
secondand coarser, 3 formillisecond, 6 formicrosecond— which wrote a moment earlier than the end. Pass thatfractionalSecondDigitsto keep the previous string.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
value | string | ISO 8601 time string |
unit | EndOfTimeUnit | EndOfTimeUnit to specify the unit for the end |
Options
Section titled “Options”optionsArg
How the result is written
| Option | Type | Default | Description |
|---|---|---|---|
fractionalSecondDigits? | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | "auto" | 8 | 9 (FractionalDigit) | 9 | The number of fractional-second digits the result is written with, 0 to 9, or "auto" to drop trailing zeros. Fewer than 9 digits truncate the string, as Temporal’s toString does, so it names a moment before the end. |
Returns
Section titled “Returns”ISO 8601 string representing the end of the specified unit, or "" on invalid input
EndOfTimeUnit
Section titled “EndOfTimeUnit”Units endOfTime accepts: a Temporal time unit, or "day" for the last moment of the day, each singular or plural.
import type { EndOfTimeUnit } from "@northguild/gmt";"day" | TimeUnit | PluralUnit<"day" | TimeUnit>Related types
Section titled “Related types”Examples
Section titled “Examples”import { endOfTime } from "@northguild/gmt/plain/calculate";
endOfTime("12:34:56", "hour") // "12:59:59.999999999"