import type { LocaleOrOptions } from './intlCache'; export declare const SECOND_MS = 1000; export declare const MINUTE_MS: number; export declare const HOUR_MS: number; export declare const DAY_MS: number; export declare const WEEK_MS: number; export declare const SECONDS_IN_MINUTE = 60; export declare const SECONDS_IN_HOUR = 3600; export declare const SECONDS_IN_DAY = 86400; export declare const SECONDS_IN_WEEK = 604800; export declare const DAYS: string[]; export declare const MONTHS: string[]; export declare const pad: (n: number) => string; /** Month number 1-12 of an English month name, short or full, in any case (`jul`, `Jul`, `JULY`), or `null` when it names no month. */ export declare function parseMonthName(name: string): number | null; export declare function getDaysInMonth(month: number, year: number): number; /** * Determine whether a year is a leap year (366 days). * * Follows the Gregorian rule: divisible by 4, except centuries which must * also be divisible by 400 (so 2000 is a leap year, 1900 is not). * * @param year - The full year, e.g. `2024`. * @returns `true` when the year has a 29th of February. */ export declare function isLeapYear(year: number): boolean; export declare function calculateEaster(year: number): Date; export declare function getFrenchHolidays(year: number): string[]; export declare function isHoliday(date: Date | string): boolean; /** * Convert a human-readable duration into milliseconds. * * Supports single units (`'5m'`) as well as compound durations made of * several space-separated (or concatenated) parts, e.g. `'1d 7h'` or `'1d7h30m'`. * * A leading `-` makes the duration negative, as `formatDuration` writes it. * Units are case-sensitive: `m` is minutes while `M` is months. * Supported units: `s`, `m`, `h`, `d`, `w`, `M`, `y`. * * The inverse of `formatDuration` in its short mode. * * @param duration - A duration string, or a number that is returned unchanged (already ms). * @returns The duration in milliseconds, or `0` when no valid part is found. */ export declare function parseDuration(duration: string | number): number; export interface FormatRelativeTimeOptions extends Intl.RelativeTimeFormatOptions { /** The date to measure against. Defaults to `new Date()`. */ from?: Date | string | number; /** A BCP 47 locale (or locales) for the output. Defaults to the runtime locale. */ locale?: string | string[]; /** Whether to use phrases like `'yesterday'` (`'auto'`) or always numeric. Defaults to `'auto'`. */ numeric?: 'auto' | 'always'; } /** * Format the distance between two dates as a human-readable phrase. * * Picks the largest sensible unit (e.g. `'3 hours ago'`, `'in 2 days'`) using * the platform's {@link Intl.RelativeTimeFormat}, so output is localized. * * @param date - The target date (past or future). * @param localeOrOptions - A locale, or an options object with the locale, reference date and `Intl.RelativeTimeFormat` options. * @returns A localized relative-time string. */ export declare function formatRelativeTime(date: Date | string | number, localeOrOptions?: LocaleOrOptions): string; /** Short day-month label in the locale's order, e.g. "15 Jan" with the default `en-GB` (never the US month-first order). */ export declare function formatDayMonth(d: Date, localeOrOptions?: LocaleOrOptions): string; /** Short month-year label, e.g. "Jan 2026". */ export declare function formatMonthYear(d: Date, localeOrOptions?: LocaleOrOptions): string; /** Short month label, e.g. "Jan". */ export declare function formatMonthShort(d: Date, localeOrOptions?: LocaleOrOptions): string; /** Parse a date label in `YYYY-MM-DD` (a time may follow), `YYYYMMDD` or `D/M/Y` form (`M/D/Y` with `order: 'month-first'`) into a local-midnight Date, or `null` when it names no real day. */ export declare function parseDateLabel(label: string, { order }?: { order?: 'day-first' | 'month-first'; }): Date | null; /** Local-date ISO string `YYYY-MM-DD` without UTC shift (unlike `toISOString`). */ export declare function toISODate(d: Date): string; /** Parse a `YYYY-MM-DD` string into a local-midnight Date, or `null` when it names no real day (`2024-02-30` included). */ export declare function fromISODate(iso: string): Date | null; /** A `getDay()` number, 0 for Sunday to 6 for Saturday. */ export type WeekDay = 0 | 1 | 2 | 3 | 4 | 5 | 6; /** Week start (Monday by default, ISO) of the given date, as `YYYY-MM-DD`. DST-proof via local arithmetic. */ export declare function startOfWeekISO(d: Date, weekStart?: WeekDay): string; /** Ascending `YYYY-MM-DD` keys for a contribution grid: a `weeks`-week window ending on `today`, padded back to the preceding `weekStart` (Monday by default) so the result is always a clean 7×N block. */ export declare function gridDays(weeks: number, today?: Date, weekStart?: WeekDay): string[]; /** An hour of the day as a clock label, e.g. 7 -> "07:00". */ export declare function formatHour(hour: number): string; /** Localized short date-time label, e.g. "Jan 15, 03:04 PM", in the runtime locale unless one is named. */ export declare function formatTime(value: Date | number, localeOrOptions?: LocaleOrOptions): string; /** Return a new Date shifted by `days` (may be negative). Does not mutate the input. */ export declare function addDays(date: Date, days: number): Date; /** Return a new Date shifted by `months`, clamping the day to the target month's length. */ export declare function addMonths(date: Date, months: number): Date; /** Return a new Date shifted by `years`, clamping Feb 29 to Feb 28 on non-leap years. */ export declare function addYears(date: Date, years: number): Date; /** Whole days from `a` to `b` (positive when `b` is later), computed on local calendar days (DST-safe). */ export declare function getDaysBetween(a: Date, b: Date): number; export interface DateDifference { days: number; weeks: number; workingDays: number; hours: number; /** Whole years, months and days, counted on the calendar. */ calendar: { years: number; months: number; days: number; }; } export interface BusinessDayOptions { /** `getDay()` numbers of the days off each week. Defaults to Saturday and Sunday. */ weekendDays?: readonly WeekDay[]; /** Also skips holidays: `true` for `isHoliday` (French public holidays), or a predicate of your own. Defaults to none. */ holidays?: boolean | ((date: Date) => boolean); } /** The span between two `YYYY-MM-DD` dates, in whichever order, counting days over `[from, to)` like any diff (unlike `businessDaysBetween`, which counts both ends), counted on UTC days so a daylight saving change never shifts it by an hour; `null` when either does not parse. `options` set what `workingDays` skips. */ export declare function dateDifference(from: string, to: string, options?: BusinessDayOptions): DateDifference | null; /** Whole hours from `a` to `b` (positive when `b` is later). */ export declare function getHoursBetween(a: Date, b: Date): number; /** New Date at the start of `date`'s day (00:00:00.000 local). */ export declare function startOfDay(date: Date): Date; /** New Date at the end of `date`'s day (23:59:59.999 local). */ export declare function endOfDay(date: Date): Date; /** New Date at the start of `date`'s month. */ export declare function startOfMonth(date: Date): Date; /** New Date at the end of `date`'s month (23:59:59.999 local on the last day). */ export declare function endOfMonth(date: Date): Date; /** Whether two dates fall on the same local calendar day. */ export declare function isSameDay(a: Date, b: Date): boolean; /** Whether `date` falls on one of `weekendDays`, Saturday or Sunday by default. */ export declare function isWeekend(date: Date, { weekendDays }?: Pick): boolean; /** Whether `date` is on the current local calendar day. */ export declare function isToday(date: Date): boolean; export interface IsBetweenOptions { /** Whether the bounds themselves count. Defaults to `true`. */ inclusive?: boolean; } /** Whether `date` is within `[start, end]`, inclusive by default. */ export declare function isBetween(date: Date, start: Date, end: Date, { inclusive }?: IsBetweenOptions): boolean; /** ISO 8601 week number (1-53), where weeks start on Monday. */ export declare function getWeekNumber(date: Date): number; /** Calendar quarter of `date` (1-4). */ export declare function getQuarter(date: Date): number; /** Full years elapsed from `birth` to `at` (defaults to now). */ export declare function getAge(birth: Date, at?: Date): number; /** Count of working days within `[start, end]`, both ends included as Excel's NETWORKDAYS does (unlike `dateDifference`, which counts `[from, to)`), Mon-Fri unless `options` say otherwise. Order-insensitive. */ export declare function businessDaysBetween(start: Date, end: Date, options?: BusinessDayOptions): number; export interface FormatSessionTimeOptions extends Pick { /** Defaults to the runtime's locale. */ locale?: string | string[]; labels?: { yesterday?: string; }; /** The moment the label is relative to. Defaults to now. */ now?: Date | number; } /** Relative session label: time today, "Yesterday", weekday within a week, else short date; days are counted on the calendar. */ export declare function formatSessionTime(date: Date, localeOrOptions?: LocaleOrOptions): string; //# sourceMappingURL=date.d.ts.map