Skip to content

endOfDateTime

endOfDateTime(value: string, unit: any, optionsArg?: { weekStartsOn?: "monday" | "sunday"; fractionalSecondDigits?: FractionalDigit; }): string
import { endOfDateTime } from "@northguild/gmt/plain/calculate";

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

  • Returns “” for invalid inputs.
Parameter Type Description
value string ISO 8601 datetime string
unit any Temporal.DateUnit | Temporal.TimeUnit to specify the unit for the end

options

Option Type Default
weekStartsOn? "monday" | "sunday"
fractionalSecondDigits? FractionalDigit

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

endOfDateTime("2024-02-29T12:34:56", "month") // "2024-02-29T23:59:59.999999999"
endOfDateTime("invalid-date", "month") // ""

plain/calculate/endOfDateTime.ts