1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | export declare class Duration {
|
10 | |
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 | static millis(amount: number): Duration;
|
17 | |
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 | static seconds(amount: number): Duration;
|
24 | |
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 | static minutes(amount: number): Duration;
|
31 | |
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 | static hours(amount: number): Duration;
|
38 | |
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 | static days(amount: number): Duration;
|
45 | |
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 |
|
52 | static parse(duration: string): Duration;
|
53 | private readonly amount;
|
54 | private readonly unit;
|
55 | private constructor();
|
56 | /**
|
57 | * Add two Durations together
|
58 | */
|
59 | plus(rhs: Duration): Duration;
|
60 | /**
|
61 | * Substract two Durations together
|
62 | */
|
63 | minus(rhs: Duration): Duration;
|
64 | /**
|
65 | * Return the total number of milliseconds in this Duration
|
66 | *
|
67 | * @returns the value of this `Duration` expressed in Milliseconds.
|
68 | */
|
69 | toMilliseconds(opts?: TimeConversionOptions): number;
|
70 | /**
|
71 | * Return the total number of seconds in this Duration
|
72 | *
|
73 | * @returns the value of this `Duration` expressed in Seconds.
|
74 | */
|
75 | toSeconds(opts?: TimeConversionOptions): number;
|
76 | /**
|
77 | * Return the total number of minutes in this Duration
|
78 | *
|
79 | * @returns the value of this `Duration` expressed in Minutes.
|
80 | */
|
81 | toMinutes(opts?: TimeConversionOptions): number;
|
82 | /**
|
83 | * Return the total number of hours in this Duration
|
84 | *
|
85 | * @returns the value of this `Duration` expressed in Hours.
|
86 | */
|
87 | toHours(opts?: TimeConversionOptions): number;
|
88 | /**
|
89 | * Return the total number of days in this Duration
|
90 | *
|
91 | * @returns the value of this `Duration` expressed in Days.
|
92 | */
|
93 | toDays(opts?: TimeConversionOptions): number;
|
94 | /**
|
95 | * Return an ISO 8601 representation of this period
|
96 | *
|
97 | * @returns a string starting with 'P' describing the period
|
98 | * @see https://www.iso.org/fr/standard/70907.html
|
99 | */
|
100 | toIsoString(): string;
|
101 | /**
|
102 | * Return an ISO 8601 representation of this period
|
103 | *
|
104 | * @returns a string starting with 'P' describing the period
|
105 | * @see https://www.iso.org/fr/standard/70907.html
|
106 | * @deprecated Use `toIsoString()` instead.
|
107 | */
|
108 | toISOString(): string;
|
109 | /**
|
110 | * Turn this duration into a human-readable string
|
111 | */
|
112 | toHumanString(): string;
|
113 | /**
|
114 | * Returns a string representation of this `Duration`
|
115 | *
|
116 | * This is is never the right function to use when you want to use the `Duration`
|
117 | * object in a template. Use `toSeconds()`, `toMinutes()`, `toDays()`, etc. instead.
|
118 | */
|
119 | toString(): string;
|
120 | /**
|
121 | * Return the duration in a set of whole numbered time components, ordered from largest to smallest
|
122 | *
|
123 | * Only components != 0 will be returned.
|
124 | *
|
125 | * Can combine millis and seconds together for the benefit of toIsoString,
|
126 | * makes the logic in there simpler.
|
127 | */
|
128 | private components;
|
129 | /**
|
130 | * Checks if duration is a token or a resolvable object
|
131 | */
|
132 | isUnresolved(): boolean;
|
133 | /**
|
134 | * Returns unit of the duration
|
135 | */
|
136 | unitLabel(): string;
|
137 | /**
|
138 | * Returns stringified number of duration
|
139 | */
|
140 | formatTokenToNumber(): string;
|
141 | }
|
142 | /**
|
143 | * Options for how to convert time to a different unit.
|
144 | */
|
145 | export interface TimeConversionOptions {
|
146 | |
147 |
|
148 |
|
149 |
|
150 |
|
151 |
|
152 | readonly integral?: boolean;
|
153 | }
|