/** * Readonly map of supported recurrence interval units. * * Use as the `unit` value inside a rule object passed to `genRecurDateBasedList`. * * Keys / values: `millisecond`, `minute`, `hour`, `day`, `week`, `month`, `year`. * * @constant */ declare const INTERVAL_UNITS: { readonly millisecond: "millisecond"; readonly minute: "minute"; readonly hour: "hour"; readonly day: "day"; readonly week: "week"; readonly month: "month"; readonly year: "year"; }; /** * Readonly map of supported iteration directions. * * - `DIRECTIONS.forward` — iterate from `start` toward the future. * - `DIRECTIONS.backward` — iterate from `start` toward the past. * * @constant */ declare const DIRECTIONS: { readonly backward: "backward"; readonly forward: "forward"; }; /** * Readonly list of supported date/time format strings. Use with `outputFormat` in {@link genRecurDateBasedList} or as the second argument to {@link formatDate}; compatible with `localeString.lang`, not with `localeString.formatOptions`. * * Includes: ISO (e.g. YYYY-MM-DD, YYYY-MM, YYYY-MM-DD HH:MM); US slash and dash (MM/DD/YYYY, MM-DD-YYYY, with time); European dot and dash (DD.MM.YYYY, DD-MM-YYYY, with time); month-year only (MMMM YYYY, MMM YYYY); RFC-style (DD MMM YYYY HH:MM:SS); weekday + date/time (EEE, DD MMM YYYY HH:MM:SS); time-only (HH:MM, HH:MM:SS, with A or Z); and compact (YYYYMMDD). * * Token meanings (all uppercase): YYYY = 4-digit year, YY = 2-digit year; MM = month 2-digit, M = month no zero; DD = day 2-digit, D = day no zero; HH = hour (12h if format contains ` A`, else 24h); MM after colon = minutes; SS = seconds, SSS = milliseconds; A = AM/PM; EEE = weekday short (locale), EEEE = weekday long; MMM = month short (locale), MMMM = month long; DDD = day of year (3-digit); Z = timezone offset (+HH:mm). * * @constant */ declare const OUTPUT_FORMATS: readonly ["MM/DD/YYYY", "MM/D/YYYY", "M/DD/YYYY", "M/D/YYYY", "DD/MM/YYYY", "D/MM/YYYY", "DD/M/YYYY", "D/M/YYYY", "YYYY-MM-DD", "YYYY-MM-D", "YYYY-MM", "DD-MM-YYYY", "D-MM-YYYY", "MM-DD-YYYY", "M-DD-YYYY", "MM-D-YYYY", "M-D-YYYY", "YYYY/MM/DD", "YYYY/MM/D", "MMM DD, YYYY", "MMM D, YYYY", "MMMM DD, YYYY", "MMMM D, YYYY", "MMMM YYYY", "MMM YYYY", "EEEE, MMMM DD, YYYY", "EEEE, MMMM D, YYYY", "EEEE, DD MMM YYYY", "EEEE, D MMM YYYY", "DD MMM YYYY", "D MMM YYYY", "DD MMMM YYYY", "D MMMM YYYY", "DD MMM YYYY HH:MM", "D MMM YYYY HH:MM", "DD MMM YYYY HH:MM:SS", "D MMM YYYY HH:MM:SS", "DD MMM YYYY HH:MM A", "D MMM YYYY HH:MM A", "DD MMM YYYY HH:MM:SS A", "D MMM YYYY HH:MM:SS A", "DD MMMM YYYY HH:MM", "D MMMM YYYY HH:MM", "DD MMMM YYYY HH:MM:SS", "D MMMM YYYY HH:MM:SS", "DD MMMM YYYY HH:MM A", "D MMMM YYYY HH:MM A", "DD MMMM YYYY HH:MM:SS A", "D MMMM YYYY HH:MM:SS A", "MMMM DD, YYYY HH:MM", "MMMM D, YYYY HH:MM", "MMMM DD, YYYY HH:MM:SS", "MMMM D, YYYY HH:MM:SS", "MMMM DD, YYYY HH:MM A", "MMMM D, YYYY HH:MM A", "MMMM DD, YYYY HH:MM:SS A", "MMMM D, YYYY HH:MM:SS A", "EEEE, MMMM DD, YYYY HH:MM", "EEEE, MMMM DD, YYYY HH:MM:SS", "EEEE, MMMM DD, YYYY HH:MM A", "EEEE, MMMM DD, YYYY HH:MM:SS A", "EEEE, MMMM D, YYYY HH:MM", "EEEE, MMMM D, YYYY HH:MM:SS", "EEEE, MMMM D, YYYY HH:MM A", "EEEE, MMMM D, YYYY HH:MM:SS A", "EEEE, DD MMM YYYY HH:MM", "EEEE, DD MMM YYYY HH:MM:SS", "EEEE, DD MMM YYYY HH:MM A", "EEEE, DD MMM YYYY HH:MM:SS A", "EEEE, D MMM YYYY HH:MM", "EEEE, D MMM YYYY HH:MM:SS", "EEEE, D MMM YYYY HH:MM A", "EEEE, D MMM YYYY HH:MM:SS A", "EEE, DD MMM YYYY HH:MM", "EEE, D MMM YYYY HH:MM", "EEE, DD MMM YYYY HH:MM:SS", "EEE, D MMM YYYY HH:MM:SS", "EEE, DD MMM YYYY HH:MM:SS A", "EEE, D MMM YYYY HH:MM:SS A", "EEE, DD MMM YYYY HH:MM:SS.SSS", "EEE, D MMM YYYY HH:MM:SS.SSS", "EEE, DD MMM YYYY HH:MM:SS.SSS A", "EEE, D MMM YYYY HH:MM:SS.SSS A", "YY/MM/DD", "YY/MM/D", "YY-MM-DD", "YY-MM-D", "MM/DD/YY", "M/D/YY", "DD/MM/YY", "D/M/YY", "YYYYMMDD", "YYYYDDD", "DD.MM.YYYY", "D.MM.YYYY", "DD.MM.YY", "D.MM.YY", "YYYY.MM.DD", "YYYY.MM.D", "D.M.YYYY", "DD.MM.YYYY HH:MM", "D.MM.YYYY HH:MM", "DD.MM.YYYY HH:MM:SS", "D.MM.YYYY HH:MM:SS", "DD.MM.YY HH:MM", "D.MM.YY HH:MM", "DD.MM.YY HH:MM:SS", "D.MM.YY HH:MM:SS", "YYYY.MM.DD HH:MM", "YYYY.MM.DD HH:MM:SS", "YYYY.MM.D HH:MM", "YYYY.MM.D HH:MM:SS", "D.M.YYYY HH:MM", "D.M.YYYY HH:MM:SS", "HH:MM", "HH:MM A", "HH:MM:SS A", "HH:MM:SS.SSS A", "HH:MM Z", "HH:MM:SS Z", "HH:MM:SS", "HH:MM:SS.SSS", "YYYY-MM-DDTHH:MM", "YYYY-MM-DDTHH:MMZ", "YYYY-MM-DDTHH:MM:SS", "YYYY-MM-DDTHH:MM:SS.SSS", "YYYY-MM-DDTHH:MM:SSZ", "YYYY-MM-DDTHH:MM:SS.SSSZ", "YYYY-MM-DD HH:MM", "YYYY-MM-DD HH:MM:SS", "YYYY-MM-DD HH:MM:SS.SSS", "YYYY-MM-DD HH:MM:SS Z", "YYYY-MM-D HH:MM", "YYYY-MM-D HH:MM:SS", "MM/DD/YYYY HH:MM", "MM/D/YYYY HH:MM", "MM/DD/YYYY HH:MM A", "MM/D/YYYY HH:MM A", "MM/DD/YYYY HH:MM:SS", "MM/D/YYYY HH:MM:SS", "MM/DD/YYYY HH:MM:SS A", "MM/D/YYYY HH:MM:SS A", "M/DD/YYYY HH:MM", "M/DD/YYYY HH:MM:SS", "M/DD/YYYY HH:MM A", "M/DD/YYYY HH:MM:SS A", "M/D/YYYY HH:MM", "M/D/YYYY HH:MM:SS", "M/D/YYYY HH:MM A", "M/D/YYYY HH:MM:SS A", "DD/MM/YYYY HH:MM", "D/MM/YYYY HH:MM", "DD/MM/YYYY HH:MM A", "D/MM/YYYY HH:MM A", "DD/MM/YYYY HH:MM:SS", "D/MM/YYYY HH:MM:SS", "DD/MM/YYYY HH:MM:SS A", "D/MM/YYYY HH:MM:SS A", "DD/MM/YYYY HH:MM:SS.SSS", "DD/MM/YYYY HH:MM:SS.SSS A", "DD/M/YYYY HH:MM", "DD/M/YYYY HH:MM:SS", "DD/M/YYYY HH:MM A", "DD/M/YYYY HH:MM:SS A", "D/M/YYYY HH:MM", "D/M/YYYY HH:MM:SS", "D/M/YYYY HH:MM A", "D/M/YYYY HH:MM:SS A", "DD-MM-YYYY HH:MM", "D-MM-YYYY HH:MM", "DD-MM-YYYY HH:MM:SS", "D-MM-YYYY HH:MM:SS", "DD-MM-YYYY HH:MM A", "D-MM-YYYY HH:MM A", "DD-MM-YYYY HH:MM:SS A", "D-MM-YYYY HH:MM:SS A", "MM-DD-YYYY HH:MM", "M-DD-YYYY HH:MM", "MM-D-YYYY HH:MM", "M-D-YYYY HH:MM", "MM-DD-YYYY HH:MM:SS", "M-DD-YYYY HH:MM:SS", "MM-D-YYYY HH:MM:SS", "M-D-YYYY HH:MM:SS", "MM-DD-YYYY HH:MM A", "M-DD-YYYY HH:MM A", "MM-D-YYYY HH:MM A", "M-D-YYYY HH:MM A", "MM-DD-YYYY HH:MM:SS A", "M-DD-YYYY HH:MM:SS A", "MM-D-YYYY HH:MM:SS A", "M-D-YYYY HH:MM:SS A", "YYYY/MM/DD HH:MM", "YYYY/MM/DD HH:MM:SS", "YYYY/MM/D HH:MM", "YYYY/MM/D HH:MM:SS", "MMM DD, YYYY HH:MM", "MMM D, YYYY HH:MM", "MMM DD, YYYY HH:MM:SS", "MMM D, YYYY HH:MM:SS", "MMM DD, YYYY HH:MM A", "MMM D, YYYY HH:MM A", "MMM DD, YYYY HH:MM:SS A", "MMM D, YYYY HH:MM:SS A", "MMM DD, YYYY HH:MM:SS.SSS", "MMM D, YYYY HH:MM:SS.SSS", "MMM DD, YYYY HH:MM:SS.SSS A", "MMM D, YYYY HH:MM:SS.SSS A", "YY/MM/DD HH:MM", "YY/MM/DD HH:MM:SS", "YY/MM/D HH:MM", "YY/MM/D HH:MM:SS", "YY-MM-DD HH:MM", "YY-MM-DD HH:MM:SS", "YY-MM-D HH:MM", "YY-MM-D HH:MM:SS", "MM/DD/YY HH:MM", "MM/DD/YY HH:MM:SS", "M/D/YY HH:MM", "M/D/YY HH:MM:SS", "DD/MM/YY HH:MM", "DD/MM/YY HH:MM:SS", "D/M/YY HH:MM", "D/M/YY HH:MM:SS"]; declare const TODAY: Date; type ObjectValuesMap = T[keyof T]; type T_ArgsBase = { start: string | Date; end: number | string | Date; rules: T_Rules; numericTimeZone: number; direction: ObjectValuesMap; localeString: T_LocaleString; outputFormat?: T_OutputFormat; filter: (args: T_CallbackArgs) => boolean; extend: Record unknown>; onError: (error: T_Error) => unknown; }; /** * Input configuration object for {@link genRecurDateBasedList}. * * Every property is optional; sensible defaults are applied internally. * Mirrors the parameters table in the documentation and is useful for * annotating reusable configuration objects. */ type T_CoreInitialArgs = Partial; type T_LocaleString = { lang?: Parameters[0]; formatOptions?: Intl.DateTimeFormatOptions; }; /** * Shape of each item returned by {@link genRecurDateBasedList}. * * Always contains `date` (local), `utcDate` (UTC equivalent) and `dateStr` * (formatted string). When the generic parameter `T` is supplied (inferred * from the `extend` option), those extra properties are intersected in, * giving you a fully typed return value. * * @typeParam T - Additional properties defined by the `extend` callbacks. */ type T_CoreReturnType = { date: Date; utcDate: Date; dateStr: string; } & T; type T_CallbackArgs = Pick; interface T_Error extends Error { message: string; } type T_CronString = string; type T_Core = = {}>(args?: Omit & { extend?: { [K in keyof E]: (args: T_CallbackArgs) => E[K]; }; }) => T_CoreReturnType[]; /** * Union of all supported interval unit strings (`'millisecond' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'year'`). * * Derived from the {@link INTERVAL_UNITS} constant. */ type T_IntervalUnit = ObjectValuesMap; /** * Union of supported direction strings (`'forward' | 'backward'`). * * Derived from the {@link DIRECTIONS} constant. */ type T_Direction = ObjectValuesMap; /** Step-based recurrence (array of unit/portion) or a single cron expression string (5 fields). */ type T_Rules = T_Rule[] | T_CronString; /** * A single recurrence rule describing how far to step on each iteration. * * @property unit - The time unit to step by (e.g. `'day'`, `'week'`, `'month'`). * @property portion - How many of that unit to advance per step. */ type T_Rule = { unit: T_IntervalUnit; portion: number; }; /** * Union type of every supported output format string. Each value is one of the strings in the OUTPUT_FORMATS array (ISO, US/European date-time, month-year, RFC-style, time-only, etc.). Use for the outputFormat option or as the second argument to formatDate. * * @see OUTPUT_FORMATS */ type T_OutputFormat = (typeof OUTPUT_FORMATS)[number]; /** * Yields list of recurring dates from `start` to `end` (date or step count), stepping by `rules` in `direction`. Each item has `date`, `utcDate`, `dateStr` and property defined in the object `extend`; `filter` can skip iterations. * * @param args - Partial config (start, end, rules, direction, outputFormat, localeString, filter, extend, onError, numericTimeZone). Defaults to `DEFAULT_ARGS`; omit `start` for "now". `rules` may be an array of unit/portion or a cron string (e.g. "0 9 * * 1-5"). * @returns Array of {@link T_CoreReturnType}. * @throws {Error} On invalid config or when iteration count exceeds 99_999. */ declare const genRecurDateBasedList: T_Core; /** * Formats a date using a supported output format string from {@link OUTPUT_FORMATS}. * * **Tokens (all uppercase):** YYYY/YY (year), MM/M (month), DD/D (day), HH (hour; 12h when format contains ` A`), MM in time context (minutes), SS (seconds), SSS (milliseconds), A (AM/PM), EEE/EEEE (weekday short/long), MMM/MMMM (month short/long), DDD (day of year), Z (timezone offset e.g. +00:00). Uses local time; use result’s utcDate for UTC. Month and weekday names use the given locale. * * @param date - The Date instance to format. * @param format - One of the strings in {@link OUTPUT_FORMATS} (e.g. `'YYYY-MM-DD'`, `'YYYY-MM-DD HH:MM'`, `'MM/DD/YYYY HH:MM:SS A'`, `'DD MMM YYYY HH:MM:SS'`, `'MMMM YYYY'`). * @param locale - BCP 47 locale string for month and weekday names (default `'en-US'`). * @param numericTimeZone - Optional numeric timezone offset (e.g. 5, -8). When provided, the Z token outputs this offset instead of the machine's. * @returns The formatted date string with all tokens replaced. */ declare function formatDateByOutputFormat(date: Date, format: T_OutputFormat, locale?: string, numericTimeZone?: number): string; export { DIRECTIONS, INTERVAL_UNITS, OUTPUT_FORMATS, type T_CoreInitialArgs, type T_CoreReturnType, type T_Direction, type T_IntervalUnit, type T_OutputFormat, type T_Rule, formatDateByOutputFormat as formatDate, genRecurDateBasedList };