-
Notifications
You must be signed in to change notification settings - Fork 190
Expand file tree
/
Copy pathduration.d.ts
More file actions
30 lines (30 loc) · 1.46 KB
/
duration.d.ts
File metadata and controls
30 lines (30 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import type { DurationFormatOptions } from './duration-format-ponyfill.js';
export declare const unitNames: readonly ["year", "month", "week", "day", "hour", "minute", "second", "millisecond"];
export type Unit = typeof unitNames[number];
export declare const isDuration: (str: string) => boolean;
type Sign = -1 | 0 | 1;
export declare class Duration {
readonly years: number;
readonly months: number;
readonly weeks: number;
readonly days: number;
readonly hours: number;
readonly minutes: number;
readonly seconds: number;
readonly milliseconds: number;
readonly sign: Sign;
readonly blank: boolean;
constructor(years?: number, months?: number, weeks?: number, days?: number, hours?: number, minutes?: number, seconds?: number, milliseconds?: number);
abs(): Duration;
static from(durationLike: unknown): Duration;
static compare(one: unknown, two: unknown): -1 | 0 | 1;
toLocaleString(locale: string, opts: DurationFormatOptions): string;
}
export declare function applyDuration(date: Date | number, duration: Duration): Date;
export declare function elapsedTime(date: Date, precision?: Unit, now?: number): Duration;
interface RoundingOpts {
relativeTo: Date | number;
}
export declare function roundToSingleUnit(duration: Duration, { relativeTo }?: Partial<RoundingOpts>): Duration;
export declare function getRelativeTimeUnit(duration: Duration, opts?: Partial<RoundingOpts>): [number, Intl.RelativeTimeFormatUnit];
export {};