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.

20 lines • 1.09 kB
import { Temporal } from "./temporal.js"; /** * The week of the week-year a date falls in, 1 to 53. * * - `"monday"` is the ISO 8601 week. * - `"sunday"` is the UTS #35 week of year with Sunday as the first day and a minimal first * week of one day: a week belongs to the week-year of its Saturday, and week 1 is the one whose * Saturday falls in 1 to 7 January. It is counted on the day of the year, so a week ending past * +275760-09-13 still resolves. * - Only the ISO calendar has these weeks; any other calendar returns `null`. * * @param date the date * @param weekStartsOn the first day of the week * @returns the week number, or `null` for a non-ISO calendar or a date Temporal cannot number * * @example weekNumberOf(Temporal.PlainDate.from("2024-01-08"), "monday") // 2 * @example weekNumberOf(Temporal.PlainDate.from("2024-12-31"), "sunday") // 1 * @example weekNumberOf(Temporal.PlainDate.from("2024-03-15[u-ca=hebrew]"), "monday") // null */ export declare function weekNumberOf(date: Temporal.PlainDate, weekStartsOn: "monday" | "sunday"): number | null;