Skip to content

endOfTime

  • The core functions, which every industry uses.
endOfTime(value: string, unit: EndOfTimeUnit, optionsArg?: { fractionalSecondDigits?: FractionalDigit; }): string

Return the end of the specified time unit for a given ISO 8601 time string.

  • unit accepts 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 second and coarser, 3 for millisecond, 6 for microsecond — which wrote a moment earlier than the end. Pass that fractionalSecondDigits to keep the previous string.
ParameterTypeDescription
valuestringISO 8601 time string
unitEndOfTimeUnitEndOfTimeUnit to specify the unit for the end

optionsArg

How the result is written

OptionTypeDefaultDescription
fractionalSecondDigits?0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | "auto" | 8 | 9 (FractionalDigit)9The 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.

ISO 8601 string representing the end of the specified unit, or "" on invalid input

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";
"days" | "hours" | "minutes" | "seconds" | "milliseconds" | "microseconds" | "nanoseconds" | "day" | TimeUnit
import { endOfTime } from "@northguild/gmt/plain/calculate";
endOfTime("12:34:56", "hour") // "12:59:59.999999999"
output 

plain/calculate/endOfTime.ts

Accessibility
© 2026 NorthGuild · Licences

Code examples: MIT-0. Packages: MIT. Third-party data and components: their own licences, credited where they appear. Everything else: © 2026 NorthGuild, all rights reserved.