Skip to content

endOfDate

endOfDate(value: string, unit: Temporal.DateUnit, optionsArg?: { weekStartsOn?: "monday" | "sunday"; }): string
import { endOfDate } from "@northguild/gmt/plain/calculate";

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

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

options

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

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

endOfDate("2024-02-29", "month") // "2024-02-29"
endOfDate("invalid-date", "month") // ""

plain/calculate/endOfDate.ts