import { Dayjs, ManipulateType } from 'dayjs/esm/index.js'; import { Maybe } from 'yummies/types'; type RawDateToFormat = Date | string | number | Dayjs; /** * Returns a new date shifted forward by the provided number of days. * * @example * ```ts * addDays(new Date('2024-03-15'), 7); * ``` */ declare const addDays: (date: RawDateToFormat, count: number) => Date | undefined; /** * Returns a new date shifted forward by the provided number of minutes. * * @example * ```ts * addMinutes(new Date('2024-03-15T12:00:00'), 15); * ``` */ declare const addMinutes: (date: RawDateToFormat, count: number) => Date | undefined; type DateChangeParam = [amount: number, unit?: Maybe]; /** * Applies one or more date adjustments and returns a new `Date` instance. * * @example * ```ts * changeDate(new Date(), 1, 'day', 30, 'minute'); * ``` */ declare const changeDate: (date: Maybe, ...args: [...DateChangeParam, ...Partial, ...Partial, ...Partial, ...Partial, ...Partial]) => Date; /** * Splits a duration in milliseconds into day-based time parts. * * @example * ```ts * dayTimeDuration(ms(1, 'day') + ms(2, 'hour')); * ``` */ declare const dayTimeDuration: (timeInMs: number) => { days: number; hours: number; minutes: number; seconds: number; milliseconds: number; }; /** * Formats a date-like value using predefined presets or a custom pattern. * * @example * ```ts * formatDate('2024-03-15', { format: 'time-short' }); * ``` */ declare const formatDate: (value: Maybe, settings?: Maybe<{ format?: "human" | "full" | "short" | "day" | "day-only" | "date" | "month" | "spent-time" | "time" | "time-short"; pattern?: string; asTime?: boolean; }>) => string; /** * Formats a duration either from milliseconds or between two dates. * * @example * ```ts * getFormatDuration(ms(2, 'hour') + ms(15, 'min')); * ``` */ declare function getFormatDuration(dateA: Date, dateB: Date, compact?: boolean): string; declare function getFormatDuration(ms: number, compact?: boolean): string; type TimeDiff = { minutes: number; seconds: number; total: { ms: number; hours: number; }; }; /** * Calculates the difference between two dates in minutes, seconds and total units. * * @example * ```ts * getTimeDiff(new Date('2024-03-15T12:30:00'), new Date('2024-03-15T12:00:00')); * ``` */ declare const getTimeDiff: (dateA: RawDateToFormat, dateB: RawDateToFormat) => TimeDiff; /** * Returns a new date with the hours field replaced. * * @example * ```ts * setHours(new Date('2024-03-15T12:00:00'), 9); * ``` */ declare const setHours: (date: RawDateToFormat, hours: number) => Date | undefined; /** * Returns a new date with the minutes field replaced. * * @example * ```ts * setMinutes(new Date('2024-03-15T12:00:00'), 45); * ``` */ declare const setMinutes: (date: RawDateToFormat, minutes: number) => Date | undefined; /** * Returns a new date shifted backward by the provided number of days. * * @example * ```ts * subtractDays(new Date('2024-03-15'), 7); * ``` */ declare const subtractDays: (date: RawDateToFormat, count: number) => Date | undefined; /** * Converts milliseconds into hour-based time parts without keeping full days separately. * * @example * ```ts * timeDuration(ms(1, 'hour') + ms(30, 'min')); * ``` */ declare const timeDuration: (timeInMs: number) => { hours: number; milliseconds: number; minutes: number; seconds: number; }; export { addDays, addMinutes, changeDate, dayTimeDuration, formatDate, getFormatDuration, getTimeDiff, setHours, setMinutes, subtractDays, timeDuration }; export type { RawDateToFormat, TimeDiff };