@burglekitt/gmt
Version:
Temporal-based date and time utilities with timezone support and polyfill integration
20 lines (19 loc) • 939 B
TypeScript
import { Temporal } from "@js-temporal/polyfill";
import type { FractionalDigit } from "../../types/index.js";
/**
* Return the start of the specified date-time `unit` for a given ISO 8601 datetime string.
*
* - Returns "" for invalid inputs.
*
* @param value ISO 8601 datetime string
* @param unit Temporal.DateUnit|Temporal.TimeUnit to specify the unit for the start
* @param optionsArg optional: weekStartsOn ("monday" | "sunday"), fractionalSecondDigits (number)
* @returns ISO 8601 string representing the start of the specified unit, or "" on invalid input
*
* @example startOfDateTime("2024-02-29T12:34:56", "month") // "2024-02-01T00:00:00"
* @example startOfDateTime("invalid-datetime", "month") // ""
*/
export declare function startOfDateTime(value: string, unit: Temporal.DateUnit | Temporal.TimeUnit, optionsArg?: {
weekStartsOn?: "monday" | "sunday";
fractionalSecondDigits?: FractionalDigit;
}): string;