import type { Timezone } from "./Timezone"; import type { Root } from "../Root"; /** * A unit of time. */ export declare type TimeUnit = "millisecond" | "second" | "minute" | "hour" | "day" | "week" | "month" | "year"; /** * A span of time, such as 5 minutes: `{ timeUnit: "minute", count: 5 }`. */ export interface ITimeInterval { /** * Unit of the interval. */ timeUnit: TimeUnit; /** * How many units the interval spans. */ count: number; } /** * Returns a promise that resolves after `ms` milliseconds. * * @param ms Sleep duration in ms * @return Promise */ export declare function sleep(ms: number): Promise; /** * Maps time period names to their numeric representations in milliseconds. * * @ignore Exclude from docs */ export declare let timeUnitDurations: { [Key in TimeUnit]: number; }; /** * Returns the next time unit that goes after source `unit`. * * E.g. "hour" is the next unit after "minute", etc. * * @ignore Exclude from docs * @param unit Source time unit * @return Next time unit */ export declare function getNextUnit(unit: TimeUnit): TimeUnit | undefined; /** * Returns the length of `count` units of time, in milliseconds. A month counts * as an average month (about 30.44 days), a year as 365 days. * * @param unit Time unit * @param count Number of units; `1` if not given * @return Milliseconds */ export declare function getDuration(unit: TimeUnit, count?: number): number; /** * @ignore */ export declare function getIntervalDuration(interval: ITimeInterval | undefined): number; /** * Returns the length of `interval` in milliseconds, for the period that * `date` falls in. Days, weeks, months and years get their real length there, * such as 29 days for February 2024. * * @param interval Interval * @param date Date in the period * @param firstDateOfWeek First day of week, `0` for Sunday * @param utc Use UTC * @param timezone Use a named timezone * @return Milliseconds */ export declare function getDateIntervalDuration(interval: ITimeInterval, date: Date, firstDateOfWeek?: number, utc?: boolean, timezone?: Timezone): number; /** * Returns current `Date` object. * * @return Current date */ export declare function now(): Date; /** * Returns current timestamp. * * @return Current timestamp */ export declare function getTime(): number; /** * Returns a copy of the `Date` object. * * @param date Source date * @return Copy */ export declare function copy(date: Date): Date; /** * Returns `true` if two timestamps fall in different periods of `unit`, such * as on different days for `"day"`. * * @param timeOne First timestamp * @param timeTwo Second timestamp * @param unit Time unit to check * @param utc Use UTC * @param timezone Use a named timezone * @return Range? */ export declare function checkChange(timeOne: number, timeTwo: number, unit: TimeUnit, utc?: boolean, timezone?: Timezone): boolean; /** * Adds `count` units of time to `date`. Changes `date` itself and returns it. * * @param date Source date * @param unit Time unit * @param count Number of units to add * @param utc Use UTC * @param timezone Use a named timezone * @return Modified date */ export declare function add(date: Date, unit: TimeUnit, count: number, utc?: boolean, timezone?: Timezone): Date; /** * @ignore */ export declare function roun(time: number, unit: TimeUnit, count: number, root: Root, firstTime?: number): number; /** * Rounds a date down to the start of its period of `count` units, such as to * midnight for `"day"`. May change `date` itself. * * @param date Source date * @param unit Time unit * @param count Number of units to round to * @param firstDateOfWeek First day of week, `0` for Sunday; `1` (Monday) if not given * @param utc Use UTC timezone * @param firstDate Date to count periods from, for `"day"` and `"week"` with `count` above `1` * @param timezone Use specific named timezone when rounding * @return New date */ export declare function round(date: Date, unit: TimeUnit, count: number, firstDateOfWeek?: number, utc?: boolean, firstDate?: Date, timezone?: Timezone): Date; /** * @ignore */ export declare function chooseInterval(index: number, duration: number, gridCount: number, intervals: Array): ITimeInterval; /** * @ignore */ export declare function getUnitValue(date: Date, unit: TimeUnit): number; //# sourceMappingURL=Time.d.ts.map