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.

26 lines • 1.34 kB
import { DateCycleField } from "../types/date-cycle-field.js"; import "../types/index.js"; /** * Return the inclusive wrap bounds for a `DateCycleField`, or `null` for `year` (unbounded — see * `cycleFieldValue`'s doc). * * - `month` bounds use `source.monthsInYear` and `day` bounds use `source.daysInMonth` rather than * hardcoded `12`/`31` — both work identically on `Temporal.PlainDate`, `PlainDateTime`, and * `ZonedDateTime`, all of which expose these calendar-derived properties. `day`'s bounds are * always the **current** month's `daysInMonth`, never the target month's — cycling `day` never * changes `month`. * * @param field the date field being cycled * @param source an object exposing `monthsInYear` and `daysInMonth` (any Temporal date-bearing type) * @example dateCycleFieldBounds("year", { monthsInYear: 12, daysInMonth: 31 }) // null * @example dateCycleFieldBounds("month", { monthsInYear: 12, daysInMonth: 31 }) // { min: 1, max: 12 } * @example dateCycleFieldBounds("day", { monthsInYear: 12, daysInMonth: 29 }) // { min: 1, max: 29 } * @returns `{ min, max }` inclusive bounds, or `null` when the field is unbounded */ export declare function dateCycleFieldBounds(field: DateCycleField, source: { monthsInYear: number; daysInMonth: number; }): { min: number; max: number; } | null;