UNPKG

1.53 kBTypeScriptView Raw
1/**
2 * Simplified interface analogous to the tc39 Temporal.Duration
3 * parameter to from(). This doesn't support the full gamut (years, days).
4 */
5export interface DurationLike {
6 hours?: number;
7 minutes?: number;
8 seconds?: number;
9 millis?: number;
10}
11/**
12 * Simplified list of values to pass to Duration.totalOf(). This
13 * list is taken from the tc39 Temporal.Duration proposal, but
14 * larger and smaller units have been left off.
15 */
16export declare type TotalOfUnit = 'hour' | 'minute' | 'second' | 'millisecond';
17/**
18 * Duration class with an interface similar to the tc39 Temporal
19 * proposal. Since it's not fully finalized, and polyfills have
20 * inconsistent compatibility, for now this shim class will be
21 * used to set durations in Pub/Sub.
22 *
23 * This class will remain here for at least the next major version,
24 * eventually to be replaced by the tc39 Temporal built-in.
25 *
26 * https://tc39.es/proposal-temporal/docs/duration.html
27 */
28export declare class Duration {
29 private millis;
30 private static secondInMillis;
31 private static minuteInMillis;
32 private static hourInMillis;
33 private constructor();
34 /**
35 * Calculates the total number of units of type 'totalOf' that would
36 * fit inside this duration.
37 */
38 totalOf(totalOf: TotalOfUnit): number;
39 /**
40 * Creates a Duration from a DurationLike, which is an object
41 * containing zero or more of the following: hours, seconds,
42 * minutes, millis.
43 */
44 static from(durationLike: DurationLike): Duration;
45}