UNPKG

@northguild/gmt

Version:

Date and time library for JavaScript and TypeScript, built on TC39 Temporal: time zones, DST, business days, ISO 8601 strings in and out. Never throws.

27 lines • 1.26 kB
/** * Return the week number for a given ISO 8601 datetime string. * * - The week is the week of the week-year, 1–53, under either numbering — see `getWeekNumber`. * - Returns null for invalid input. * * @param value ISO 8601 datetime string * @param optionsArg How weeks are numbered * @returns Week number (1-53) or null on invalid input * * @example parseWeekFromDateTime("2024-01-01T12:00:00") // 1 * @example parseWeekFromDateTime("2024-01-08T00:00:00") // 2 * @example parseWeekFromDateTime("2024-01-01T00:00:00", { weekStartsOn: "sunday" }) // 1 * @example parseWeekFromDateTime("invalid") // null * @example parseWeekFromDateTime("2024-12-31T12:00:00", { weekStartsOn: "sunday" }) // 1 (its Sunday-first week holds 1 January 2025) */ export declare function parseWeekFromDateTime(value: string, optionsArg?: { /** * The first day of the week, which sets how the week is numbered. `"monday"` gives the ISO 8601 * week number, where week 1 holds the year's first Thursday; `"sunday"` gives the UTS #35 week * number with a Sunday first day and one minimal day, where week 1 holds 1 January. Any other * value returns `null`. * * @defaultValue `"monday"` */ weekStartsOn?: "monday" | "sunday"; }): number | null;