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.

24 lines • 1.36 kB
import { WeekdayOrdinal } from "../../types/holiday-rule.js"; import "../../types/index.js"; /** * The `n`-th `weekday` of a month, counted from the start (`1` to `5`) or from the end (`-1` to * `-5`; `"last"` is `-1`), as RFC 5545 §3.3.10 counts a `BYDAY` ordinal in a monthly rule. * * - The ISO (proleptic Gregorian) calendar only. * - A fifth occurrence a month does not have (a fifth Friday of February 2026) gives `""`: the * date is skipped, never clamped to the fourth. * - A date outside Temporal's range (-271821-04-19 to +275760-09-13) gives `""`. * - Never throws. * * @param year ISO year, an integer * @param month ISO month, 1 to 12 * @param weekday ISO weekday, Monday 1 to Sunday 7 * @param n which occurrence: `1`..`5`, `-1`..`-5` or `"last"` * @returns ISO PlainDate string of the occurrence, or `""` when it does not exist or an argument is invalid * * @example nthWeekdayOfMonth(2026, 3, 7, "last") // "2026-03-29" — the last Sunday of March * @example nthWeekdayOfMonth(2026, 1, 1, 3) // "2026-01-19" — the third Monday of January * @example nthWeekdayOfMonth(2026, 2, 5, 5) // "" — February 2026 has only four Fridays * @example nthWeekdayOfMonth(2026, 13, 1, 1) // "" — invalid month */ export declare function nthWeekdayOfMonth(year: number, month: number, weekday: number, n: WeekdayOrdinal): string;