@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.86 kB
TypeScript
import { WeekdayOrdinal } from "../types/holiday-rule.js";
import "../types/index.js";
/** True for `1..5`, `-1..-5` and `"last"`: the ordinals RFC 5545 §3.3.10 allows in a monthly `BYDAY`, plus the `"last"` alias. */
export declare function isWeekdayOrdinal(value: unknown): value is WeekdayOrdinal;
/** The signed integer an ordinal stands for: `"last"` is `-1` (GMT's readable alias for the RFC 5545 ordinal). */
export declare function ordinalNumber(n: WeekdayOrdinal): number;
/**
* Epoch day of the `n`-th ISO `weekday` in the closed day range `[first, last]` (epoch days):
* `n > 0` counts from `first`, `n < 0` from `last`. `null` when that occurrence lies outside the
* range. The range may reach past Temporal's date range and the count includes those days: a
* recurrence period counts its whole span before it drops the dates a PlainDate cannot hold.
* `n` is a nonzero integer. Closed form: the offset to the first (or last) matching weekday plus
* `7 x (|n| - 1)`, no loop.
*/
export declare function nthWeekdayWithin(first: number, last: number, weekday: number, n: number): number | null;
/**
* Epoch day of the `n`-th ISO `weekday` in the closed day range `[first, last]` (epoch days), or
* `null` when that occurrence lies outside the range or outside Temporal's date range. See
* {@link nthWeekdayWithin} for the count.
*/
export declare function nthWeekdayInRange(first: number, last: number, weekday: number, n: number): number | null;
/**
* Epoch day of the `n`-th ISO weekday of an ISO month, or `null` when that occurrence does not
* exist or lies outside Temporal's date range. `n` is an already-checked integer in
* `-5..-1` or `1..5`. Counts from the month's first day (`n > 0`) or last day (`n < 0`).
*/
export declare function nthWeekdayEpochDay(year: number, month: number, weekday: number, n: number): number | null;