Skip to content

startOfDateTime

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

Return the start 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 start

options

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

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

startOfDateTime("2024-02-29T12:34:56", "month") // "2024-02-01T00:00:00"
startOfDateTime("invalid-datetime", "month") // ""

plain/calculate/startOfDateTime.ts