@formkit/tempo 0.1.2 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -1
- package/dist/add.d.ts +11 -0
- package/dist/add.mjs +50 -0
- package/dist/add.mjs.map +1 -0
- package/dist/addDay.d.ts +4 -3
- package/dist/addDay.mjs.map +1 -1
- package/dist/addHour.d.ts +4 -3
- package/dist/addHour.mjs.map +1 -1
- package/dist/addMillisecond.d.ts +10 -0
- package/dist/addMillisecond.mjs +11 -0
- package/dist/addMillisecond.mjs.map +1 -0
- package/dist/addMinute.d.ts +5 -4
- package/dist/addMinute.mjs.map +1 -1
- package/dist/addMonth.d.ts +5 -5
- package/dist/addMonth.mjs +2 -12
- package/dist/addMonth.mjs.map +1 -1
- package/dist/addSecond.d.ts +4 -3
- package/dist/addSecond.mjs.map +1 -1
- package/dist/addYear.d.ts +5 -5
- package/dist/addYear.mjs +6 -12
- package/dist/addYear.mjs.map +1 -1
- package/dist/ap.mjs +1 -2
- package/dist/ap.mjs.map +1 -1
- package/dist/applyOffset.d.ts +5 -5
- package/dist/applyOffset.mjs +5 -11
- package/dist/applyOffset.mjs.map +1 -1
- package/dist/bundle.d.ts +365 -115
- package/dist/bundle.mjs +364 -180
- package/dist/bundle.mjs.map +1 -1
- package/dist/common.d.ts +27 -7
- package/dist/common.mjs +47 -42
- package/dist/common.mjs.map +1 -1
- package/dist/date.d.ts +2 -2
- package/dist/date.mjs +1 -3
- package/dist/date.mjs.map +1 -1
- package/dist/dayEnd.d.ts +3 -3
- package/dist/dayEnd.mjs.map +1 -1
- package/dist/dayOfYear.d.ts +3 -3
- package/dist/dayOfYear.mjs.map +1 -1
- package/dist/dayStart.d.ts +3 -3
- package/dist/dayStart.mjs +1 -1
- package/dist/dayStart.mjs.map +1 -1
- package/dist/diff.d.ts +38 -0
- package/dist/diff.mjs +86 -0
- package/dist/diff.mjs.map +1 -0
- package/dist/diffDays.d.ts +12 -5
- package/dist/diffDays.mjs +1 -0
- package/dist/diffDays.mjs.map +1 -1
- package/dist/diffHours.d.ts +12 -5
- package/dist/diffHours.mjs +1 -0
- package/dist/diffHours.mjs.map +1 -1
- package/dist/diffMilliseconds.d.ts +10 -4
- package/dist/diffMilliseconds.mjs.map +1 -1
- package/dist/diffMinutes.d.ts +11 -3
- package/dist/diffMinutes.mjs +5 -1
- package/dist/diffMinutes.mjs.map +1 -1
- package/dist/diffMonths.d.ts +10 -4
- package/dist/diffMonths.mjs.map +1 -1
- package/dist/diffSeconds.d.ts +12 -5
- package/dist/diffSeconds.mjs +5 -1
- package/dist/diffSeconds.mjs.map +1 -1
- package/dist/diffWeeks.d.ts +10 -3
- package/dist/diffWeeks.mjs.map +1 -1
- package/dist/diffYears.d.ts +10 -4
- package/dist/diffYears.mjs +4 -1
- package/dist/diffYears.mjs.map +1 -1
- package/dist/format.mjs +2 -3
- package/dist/format.mjs.map +1 -1
- package/dist/handleDateOverflow.d.ts +12 -0
- package/dist/handleDateOverflow.mjs +18 -0
- package/dist/handleDateOverflow.mjs.map +1 -0
- package/dist/hourEnd.d.ts +3 -3
- package/dist/hourEnd.mjs.map +1 -1
- package/dist/hourStart.d.ts +3 -3
- package/dist/hourStart.mjs +1 -1
- package/dist/hourStart.mjs.map +1 -1
- package/dist/index.cjs +380 -183
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +365 -115
- package/dist/index.d.ts +14 -1
- package/dist/index.mjs +26 -0
- package/dist/index.mjs.map +1 -1
- package/dist/isAfter.d.ts +6 -6
- package/dist/isAfter.mjs.map +1 -1
- package/dist/isBefore.d.ts +5 -5
- package/dist/isBefore.mjs.map +1 -1
- package/dist/isEqual.d.ts +13 -4
- package/dist/isEqual.mjs.map +1 -1
- package/dist/isFuture.d.ts +10 -0
- package/dist/isFuture.mjs +9 -0
- package/dist/isFuture.mjs.map +1 -0
- package/dist/isPast.d.ts +10 -0
- package/dist/isPast.mjs +9 -0
- package/dist/isPast.mjs.map +1 -0
- package/dist/iso8601.d.ts +1 -1
- package/dist/iso8601.mjs +4 -7
- package/dist/iso8601.mjs.map +1 -1
- package/dist/minuteEnd.d.ts +3 -3
- package/dist/minuteEnd.mjs.map +1 -1
- package/dist/minuteStart.d.ts +3 -3
- package/dist/minuteStart.mjs +1 -1
- package/dist/minuteStart.mjs.map +1 -1
- package/dist/monthDays.d.ts +3 -3
- package/dist/monthDays.mjs.map +1 -1
- package/dist/monthEnd.d.ts +3 -3
- package/dist/monthEnd.mjs.map +1 -1
- package/dist/monthStart.d.ts +3 -3
- package/dist/monthStart.mjs +1 -1
- package/dist/monthStart.mjs.map +1 -1
- package/dist/nearestDay.d.ts +3 -3
- package/dist/nearestDay.mjs +2 -4
- package/dist/nearestDay.mjs.map +1 -1
- package/dist/offset.d.ts +5 -5
- package/dist/offset.mjs +16 -16
- package/dist/offset.mjs.map +1 -1
- package/dist/parse.mjs +33 -23
- package/dist/parse.mjs.map +1 -1
- package/dist/parts.mjs +14 -24
- package/dist/parts.mjs.map +1 -1
- package/dist/range.mjs +1 -2
- package/dist/range.mjs.map +1 -1
- package/dist/removeOffset.d.ts +4 -4
- package/dist/removeOffset.mjs.map +1 -1
- package/dist/sameDay.d.ts +8 -2
- package/dist/sameDay.mjs.map +1 -1
- package/dist/sameHour.d.ts +8 -2
- package/dist/sameHour.mjs.map +1 -1
- package/dist/sameMillisecond.d.ts +16 -0
- package/dist/sameMillisecond.mjs +11 -0
- package/dist/sameMillisecond.mjs.map +1 -0
- package/dist/sameMinute.d.ts +8 -2
- package/dist/sameMinute.mjs.map +1 -1
- package/dist/sameMonth.d.ts +16 -0
- package/dist/sameMonth.mjs +11 -0
- package/dist/sameMonth.mjs.map +1 -0
- package/dist/sameSecond.d.ts +8 -2
- package/dist/sameSecond.mjs.map +1 -1
- package/dist/sameYear.d.ts +8 -2
- package/dist/sameYear.mjs.map +1 -1
- package/dist/setDayOfMonth.d.ts +11 -0
- package/dist/setDayOfMonth.mjs +16 -0
- package/dist/setDayOfMonth.mjs.map +1 -0
- package/dist/setHour.d.ts +10 -0
- package/dist/setHour.mjs +11 -0
- package/dist/setHour.mjs.map +1 -0
- package/dist/setMilliseconds.d.ts +10 -0
- package/dist/setMilliseconds.mjs +11 -0
- package/dist/setMilliseconds.mjs.map +1 -0
- package/dist/setMinutes.d.ts +10 -0
- package/dist/setMinutes.mjs +11 -0
- package/dist/setMinutes.mjs.map +1 -0
- package/dist/setMonth.d.ts +11 -0
- package/dist/setMonth.mjs +9 -0
- package/dist/setMonth.mjs.map +1 -0
- package/dist/setSeconds.d.ts +10 -0
- package/dist/setSeconds.mjs +11 -0
- package/dist/setSeconds.mjs.map +1 -0
- package/dist/setYear.d.ts +11 -0
- package/dist/setYear.mjs +9 -0
- package/dist/setYear.mjs.map +1 -0
- package/dist/types.d.ts +29 -7
- package/dist/tzDate.d.ts +5 -3
- package/dist/tzDate.mjs.map +1 -1
- package/dist/weekEnd.d.ts +4 -4
- package/dist/weekEnd.mjs +1 -1
- package/dist/weekEnd.mjs.map +1 -1
- package/dist/weekStart.d.ts +4 -4
- package/dist/weekStart.mjs +2 -3
- package/dist/weekStart.mjs.map +1 -1
- package/dist/yearDays.d.ts +3 -3
- package/dist/yearDays.mjs.map +1 -1
- package/dist/yearEnd.d.ts +3 -3
- package/dist/yearEnd.mjs +1 -2
- package/dist/yearEnd.mjs.map +1 -1
- package/dist/yearStart.d.ts +3 -3
- package/dist/yearStart.mjs +2 -3
- package/dist/yearStart.mjs.map +1 -1
- package/package.json +32 -23
package/dist/bundle.d.ts
CHANGED
|
@@ -2,10 +2,18 @@
|
|
|
2
2
|
* The date format used as an input value. Either a date or an ISO8601 string.
|
|
3
3
|
*/
|
|
4
4
|
type DateInput = Date | string;
|
|
5
|
+
/**
|
|
6
|
+
* The date format used as a maybe input value. Either a date, ISO8601 string or null for current time
|
|
7
|
+
*/
|
|
8
|
+
type MaybeDateInput = DateInput | null;
|
|
5
9
|
/**
|
|
6
10
|
* Format parts with text names use these descriptors:
|
|
7
11
|
*/
|
|
8
12
|
type NamedFormatOption = "long" | "short" | "narrow";
|
|
13
|
+
/**
|
|
14
|
+
* Extended part types that include custom tokens not in Intl.DateTimeFormatPartTypes.
|
|
15
|
+
*/
|
|
16
|
+
type ExtendedPartTypes = Intl.DateTimeFormatPartTypes | "fractionalSecond";
|
|
9
17
|
/**
|
|
10
18
|
* A registry of named format parts. Each type of part has every option.
|
|
11
19
|
*/
|
|
@@ -28,11 +36,11 @@ interface Part {
|
|
|
28
36
|
option: FormatPattern[1];
|
|
29
37
|
/**
|
|
30
38
|
* The name of the part, these must be valid parts of a date format as
|
|
31
|
-
* specified in Intl.DateTimeFormatPartTypes
|
|
32
|
-
* day, dayPeriod, era, hour, literal, minute, month,
|
|
33
|
-
* weekday, year
|
|
39
|
+
* specified in Intl.DateTimeFormatPartTypes, plus custom extensions.
|
|
40
|
+
* Valid values are: day, dayPeriod, era, hour, literal, minute, month,
|
|
41
|
+
* second, timeZoneName, weekday, year, fractionalSecond
|
|
34
42
|
*/
|
|
35
|
-
partName:
|
|
43
|
+
partName: ExtendedPartTypes;
|
|
36
44
|
/**
|
|
37
45
|
* The value of a given part. For example "2-digit", or "narrow".
|
|
38
46
|
*/
|
|
@@ -61,7 +69,7 @@ type FilledPart = Part & {
|
|
|
61
69
|
*/
|
|
62
70
|
type FormatPattern = [
|
|
63
71
|
pattern: FormatToken | string,
|
|
64
|
-
option: Partial<Record<
|
|
72
|
+
option: Partial<Record<ExtendedPartTypes, string>>,
|
|
65
73
|
exp?: RegExp
|
|
66
74
|
];
|
|
67
75
|
/**
|
|
@@ -83,7 +91,7 @@ type Format = FormatStyle | FormatStyleObj | (string & {});
|
|
|
83
91
|
/**
|
|
84
92
|
* A union of all available formatting tokens.
|
|
85
93
|
*/
|
|
86
|
-
type FormatToken = "YYYY" | "YY" | "MMMM" | "MMM" | "MM" | "M" | "DD" | "D" | "dddd" | "ddd" | "d" | "mm" | "m" | "ss" | "s" | "HH" | "H" | "hh" | "h" | "a" | "A" | "ZZ" | "Z";
|
|
94
|
+
type FormatToken = "YYYY" | "YY" | "MMMM" | "MMM" | "MM" | "M" | "DD" | "D" | "dddd" | "ddd" | "d" | "mm" | "m" | "ss" | "s" | "SSS" | "HH" | "H" | "hh" | "h" | "a" | "A" | "ZZ" | "Z";
|
|
87
95
|
interface ParseOptions {
|
|
88
96
|
/**
|
|
89
97
|
* A string representing a date.
|
|
@@ -139,50 +147,83 @@ interface FormatOptions {
|
|
|
139
147
|
*/
|
|
140
148
|
partFilter?: (part: Part) => boolean;
|
|
141
149
|
}
|
|
150
|
+
interface Duration {
|
|
151
|
+
years?: number;
|
|
152
|
+
months?: number;
|
|
153
|
+
weeks?: number;
|
|
154
|
+
days?: number;
|
|
155
|
+
hours?: number;
|
|
156
|
+
minutes?: number;
|
|
157
|
+
seconds?: number;
|
|
158
|
+
milliseconds?: number;
|
|
159
|
+
}
|
|
160
|
+
interface DurationObj extends Duration {
|
|
161
|
+
microseconds?: number;
|
|
162
|
+
nanoseconds?: number;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Returns a new Date object with the duration applied.
|
|
167
|
+
* @param [inputDate] - A date to increment or null to increment from the current time.
|
|
168
|
+
* @param duration - An object with values for the amount of time to add to the original date.
|
|
169
|
+
* @param [dateOverflow] - Whether to allow month/year changes to overflow into a later month.
|
|
170
|
+
*/
|
|
171
|
+
declare function add(inputDate: MaybeDateInput, duration: Duration, dateOverflow?: boolean): Date;
|
|
142
172
|
|
|
143
173
|
/**
|
|
144
174
|
* Returns a new date object 1/n days after the original one.
|
|
145
|
-
* @param inputDate - A date to increment
|
|
175
|
+
* @param [inputDate] - A date to increment or null to increment from the current time.
|
|
176
|
+
* @param [count] - The quantity to add.
|
|
146
177
|
*/
|
|
147
|
-
declare function addDay(inputDate
|
|
178
|
+
declare function addDay(inputDate?: MaybeDateInput, count?: number): Date;
|
|
148
179
|
|
|
149
180
|
/**
|
|
150
181
|
* Returns a new date object 1/n months after the original one. Keep in mind if you
|
|
151
182
|
* start with a date late in a given month you could get a date after the next
|
|
152
183
|
* month.
|
|
153
|
-
* @param inputDate - A date to increment
|
|
154
|
-
* @param count - The quantity to add.
|
|
155
|
-
* @param dateOverflow - Whether or not to allow the date to overflow to another month if the inputDate’s month is out of range of the new month.
|
|
184
|
+
* @param [inputDate] - A date to increment or null to increment from the current time
|
|
185
|
+
* @param [count] - The quantity to add.
|
|
186
|
+
* @param [dateOverflow] - Whether or not to allow the date to overflow to another month if the inputDate’s month is out of range of the new month.
|
|
156
187
|
*/
|
|
157
|
-
declare function addMonth(inputDate
|
|
188
|
+
declare function addMonth(inputDate?: MaybeDateInput, count?: number, dateOverflow?: boolean): Date;
|
|
158
189
|
|
|
159
190
|
/**
|
|
160
191
|
* Returns a new date object 1/n years after the original one. Keep in mind if
|
|
161
192
|
* you start with a date late in a given month you could get a date after the
|
|
162
193
|
* next month.
|
|
163
|
-
* @param inputDate - A date to increment
|
|
164
|
-
* @param count - The quantity of years add.
|
|
165
|
-
* @param dateOverflow - Whether or not to allow the date to overflow to another month if the inputDate’s month is out of range of the new month.
|
|
194
|
+
* @param [inputDate] - A date to increment or null to increment from the current time.
|
|
195
|
+
* @param [count] - The quantity of years add.
|
|
196
|
+
* @param [dateOverflow] - Whether or not to allow the date to overflow to another month if the inputDate’s month is out of range of the new month.
|
|
166
197
|
*/
|
|
167
|
-
declare function addYear(inputDate
|
|
198
|
+
declare function addYear(inputDate?: MaybeDateInput, count?: number, dateOverflow?: boolean): Date;
|
|
168
199
|
|
|
169
200
|
/**
|
|
170
201
|
* Returns a new date object 1/n hours after the original one.
|
|
171
|
-
* @param inputDate - A date to increment
|
|
202
|
+
* @param [inputDate] - A date to increment or null to increment from the current time.
|
|
203
|
+
* @param [count] - The quantity to add.
|
|
172
204
|
*/
|
|
173
|
-
declare function addHour(inputDate
|
|
205
|
+
declare function addHour(inputDate?: MaybeDateInput, count?: number): Date;
|
|
174
206
|
|
|
175
207
|
/**
|
|
176
|
-
* Returns a new date object 1/n
|
|
177
|
-
* @param inputDate - A date to increment
|
|
208
|
+
* Returns a new date object 1/n minutes after the original one.
|
|
209
|
+
* @param [inputDate] - A date to increment or null to increment from the current time.
|
|
210
|
+
* @param [count] - The quantity to add.
|
|
178
211
|
*/
|
|
179
|
-
declare function addMinute(inputDate
|
|
212
|
+
declare function addMinute(inputDate?: MaybeDateInput, count?: number): Date;
|
|
180
213
|
|
|
181
214
|
/**
|
|
182
215
|
* Returns a new date object 1/n seconds after the original one.
|
|
183
|
-
* @param inputDate - A date to increment
|
|
216
|
+
* @param [inputDate] - A date to increment or null to increment from the current time.
|
|
217
|
+
* @param [count] - The quantity to add.
|
|
218
|
+
*/
|
|
219
|
+
declare function addSecond(inputDate?: MaybeDateInput, count?: number): Date;
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Returns a new date object 1/n milliseconds after the original one.
|
|
223
|
+
* @param [inputDate] - A date to increment or null to increment from the current time.
|
|
224
|
+
* @param [count] - The quantity to add.
|
|
184
225
|
*/
|
|
185
|
-
declare function
|
|
226
|
+
declare function addMillisecond(inputDate?: MaybeDateInput, count?: number): Date;
|
|
186
227
|
|
|
187
228
|
/**
|
|
188
229
|
* Determines the correct value for am/pm by locale and memoizes it.
|
|
@@ -193,17 +234,17 @@ declare function ap(ampm: "am" | "pm", locale: string): string;
|
|
|
193
234
|
|
|
194
235
|
/**
|
|
195
236
|
* Apply a given offset to a date, returning a new date with the offset
|
|
196
|
-
* applied by adding or subtracting the given number of
|
|
197
|
-
* @param dateInput - The date to apply the offset to.
|
|
198
|
-
* @param offset - The offset to apply in the +-HHmm or +-HH:mm format.
|
|
237
|
+
* applied by adding or subtracting the given number of seconds.
|
|
238
|
+
* @param [dateInput] - The date to apply the offset to. (default: current time)
|
|
239
|
+
* @param [offset] - The offset to apply in the +-HHmm, +-HH:mm, +-HHmmss, or +-HH:mm:ss format.
|
|
199
240
|
*/
|
|
200
|
-
declare function applyOffset(dateInput
|
|
241
|
+
declare function applyOffset(dateInput?: MaybeDateInput, offset?: string): Date;
|
|
201
242
|
|
|
202
243
|
/**
|
|
203
244
|
* A date to parse.
|
|
204
245
|
* @param date - A Date object or an ISO 8601 date.
|
|
205
246
|
*/
|
|
206
|
-
declare function date(date?:
|
|
247
|
+
declare function date(date?: MaybeDateInput): Date;
|
|
207
248
|
|
|
208
249
|
/**
|
|
209
250
|
* Creates a date object for the input date at the given timezone. For example
|
|
@@ -212,29 +253,31 @@ declare function date(date?: DateInput): Date;
|
|
|
212
253
|
*
|
|
213
254
|
* If given a Date object it will use local time and convert it to the given
|
|
214
255
|
* timezone, thus "changing" the date.
|
|
215
|
-
*
|
|
256
|
+
*
|
|
257
|
+
* if given no string or date object, it'll use the current locale time and convert to the given timezone
|
|
258
|
+
* @param [inputDate] - An iso8601 date string with no timezone
|
|
216
259
|
* @param tz - A timezone string
|
|
217
260
|
*/
|
|
218
|
-
declare function tzDate(inputDate:
|
|
261
|
+
declare function tzDate(inputDate: MaybeDateInput, tz: string): Date;
|
|
219
262
|
|
|
220
263
|
/**
|
|
221
264
|
* Gets the what day of the year a given date is. For example, August 1st is
|
|
222
265
|
* the 213th day of the year on non- years and 214th on leap years.
|
|
223
|
-
* @param inputDate - The input date.
|
|
266
|
+
* @param [inputDate] - The input date or nothing for the current day.
|
|
224
267
|
*/
|
|
225
|
-
declare function dayOfYear(inputDate
|
|
268
|
+
declare function dayOfYear(inputDate?: MaybeDateInput): number;
|
|
226
269
|
|
|
227
270
|
/**
|
|
228
271
|
* Returns a Date object for end of the given day.
|
|
229
|
-
* @param inputDate - A string or
|
|
272
|
+
* @param [inputDate] - A string, Date object or nothing for the current day
|
|
230
273
|
*/
|
|
231
|
-
declare function dayEnd(inputDate
|
|
274
|
+
declare function dayEnd(inputDate?: MaybeDateInput): Date;
|
|
232
275
|
|
|
233
276
|
/**
|
|
234
277
|
* Returns a Date object for start of the given day.
|
|
235
|
-
* @param inputDate - A string or
|
|
278
|
+
* @param [inputDate] - A string, Date object or nothing for the current day
|
|
236
279
|
*/
|
|
237
|
-
declare function dayStart(inputDate
|
|
280
|
+
declare function dayStart(inputDate?: MaybeDateInput): Date;
|
|
238
281
|
|
|
239
282
|
/**
|
|
240
283
|
* Produce a formatted string. Available strings:
|
|
@@ -290,15 +333,15 @@ declare function fourDigitYear(value: string): number;
|
|
|
290
333
|
|
|
291
334
|
/**
|
|
292
335
|
* Returns a Date object for end of the given hour.
|
|
293
|
-
* @param inputDate - A string or
|
|
336
|
+
* @param [inputDate] - A string, Date object or nothing for the current time
|
|
294
337
|
*/
|
|
295
|
-
declare function hourEnd(inputDate
|
|
338
|
+
declare function hourEnd(inputDate?: MaybeDateInput): Date;
|
|
296
339
|
|
|
297
340
|
/**
|
|
298
341
|
* Returns a Date object for start of the given hour.
|
|
299
|
-
* @param inputDate - A string or
|
|
342
|
+
* @param [inputDate] - A string, Date object or nothing for the current time
|
|
300
343
|
*/
|
|
301
|
-
declare function hourStart(inputDate
|
|
344
|
+
declare function hourStart(inputDate?: MaybeDateInput): Date;
|
|
302
345
|
|
|
303
346
|
/**
|
|
304
347
|
* True when the date string is valid ISO 8601.
|
|
@@ -308,43 +351,43 @@ declare function iso8601(date: string): boolean;
|
|
|
308
351
|
|
|
309
352
|
/**
|
|
310
353
|
* Returns a Date object for end of the given minute.
|
|
311
|
-
* @param inputDate - A string or
|
|
354
|
+
* @param [inputDate] - A string, Date object or nothing for the current time
|
|
312
355
|
*/
|
|
313
|
-
declare function minuteEnd(inputDate
|
|
356
|
+
declare function minuteEnd(inputDate?: MaybeDateInput): Date;
|
|
314
357
|
|
|
315
358
|
/**
|
|
316
359
|
* Returns a Date object for start of the given minute.
|
|
317
|
-
* @param inputDate - A string or
|
|
360
|
+
* @param [inputDate] - A string, Date object or nothing for the current time
|
|
318
361
|
*/
|
|
319
|
-
declare function minuteStart(inputDate
|
|
362
|
+
declare function minuteStart(inputDate?: MaybeDateInput): Date;
|
|
320
363
|
|
|
321
364
|
/**
|
|
322
365
|
* Returns the total number of days from a given month.
|
|
323
|
-
* @param inputDate - A string or
|
|
366
|
+
* @param [inputDate] - A string, Date object or nothing for the current month
|
|
324
367
|
*/
|
|
325
|
-
declare function monthDays(inputDate
|
|
368
|
+
declare function monthDays(inputDate?: MaybeDateInput): number;
|
|
326
369
|
|
|
327
370
|
/**
|
|
328
371
|
* Returns a Date object for the with the input date set to the last day of
|
|
329
372
|
* the current month. Does not change the time.
|
|
330
|
-
* @param inputDate - A string or
|
|
373
|
+
* @param [inputDate] - A string, Date object or nothing for the current month
|
|
331
374
|
*/
|
|
332
|
-
declare function monthEnd(inputDate
|
|
375
|
+
declare function monthEnd(inputDate?: MaybeDateInput): Date;
|
|
333
376
|
|
|
334
377
|
/**
|
|
335
378
|
* Returns a Date object for the first day of a month.
|
|
336
|
-
* @param inputDate - A string or
|
|
379
|
+
* @param [inputDate] - A string, Date object or nothing for the current time
|
|
337
380
|
*/
|
|
338
|
-
declare function monthStart(inputDate
|
|
381
|
+
declare function monthStart(inputDate?: MaybeDateInput): Date;
|
|
339
382
|
|
|
340
383
|
/**
|
|
341
384
|
* Performs a bidirectional search for the nearest date that passes a function.
|
|
342
|
-
* @param
|
|
385
|
+
* @param [inputDate] - Performs a search for the nearest passing date.
|
|
343
386
|
* @param search - The search function to use, given a date returns a boolean.
|
|
344
387
|
* @param constraint - The number of iterations to perform before giving up, or logical constraint like "month", or "week".
|
|
345
388
|
*
|
|
346
389
|
*/
|
|
347
|
-
declare function nearestDay(inputDate:
|
|
390
|
+
declare function nearestDay(inputDate: MaybeDateInput, search: (date: Date) => boolean, constraint?: number | "month" | "week" | "year"): Date | null;
|
|
348
391
|
|
|
349
392
|
/**
|
|
350
393
|
* Timezone tokens.
|
|
@@ -359,11 +402,11 @@ type TimezoneToken = (typeof timeZoneTokens)[number];
|
|
|
359
402
|
* Returns the offset between two timezones on a given date. The results are
|
|
360
403
|
* ISO8601 compatible offsets like -0800 or +0530.
|
|
361
404
|
*
|
|
362
|
-
* @param dateInput - The date on which to determine the offset
|
|
363
|
-
* @param tzA - (default: UTC) The second timezone to compare determine the offset between.
|
|
364
|
-
* @param tzB - (default: device) The first timezone to compare determine the offset between.
|
|
405
|
+
* @param [dateInput] - (default: current time) The date on which to determine the offset
|
|
406
|
+
* @param [tzA] - (default: UTC) The second timezone to compare determine the offset between.
|
|
407
|
+
* @param [tzB] - (default: device) The first timezone to compare determine the offset between.
|
|
365
408
|
*/
|
|
366
|
-
declare function offset(utcTime
|
|
409
|
+
declare function offset(utcTime?: MaybeDateInput, tzA?: string, tzB?: string, timeZoneToken?: TimezoneToken): string;
|
|
367
410
|
|
|
368
411
|
declare function parse(options: ParseOptions): Date | never;
|
|
369
412
|
declare function parse(dateStr: string, format?: Format, locale?: string): Date | never;
|
|
@@ -393,177 +436,384 @@ declare function range(token: FormatToken, locale?: string, genitive?: boolean):
|
|
|
393
436
|
|
|
394
437
|
/**
|
|
395
438
|
* Inverts the offset and applies it to the given date, returning a new date.
|
|
396
|
-
* @param dateInput - The date to remove the offset from.
|
|
397
|
-
* @param offset - The offset to remove in the +-HHmm or +-HH:mm format.
|
|
439
|
+
* @param [dateInput] - The date to remove the offset from. (default: current time)
|
|
440
|
+
* @param [offset] - The offset to remove in the +-HHmm or +-HH:mm format.
|
|
398
441
|
*/
|
|
399
|
-
declare function removeOffset(dateInput
|
|
442
|
+
declare function removeOffset(dateInput?: MaybeDateInput, offset?: string): Date;
|
|
400
443
|
|
|
401
444
|
/**
|
|
402
445
|
* Checks if two date objects refer to the same date. Ignores time.
|
|
403
446
|
* @param inputDateA - First date to compare
|
|
447
|
+
* @param [inputDateB] - Second date to compare or the current time if nothing given
|
|
448
|
+
*/
|
|
449
|
+
declare function sameDay(inputDateA: DateInput, inputDateB?: MaybeDateInput): boolean;
|
|
450
|
+
/**
|
|
451
|
+
* Checks if two date objects refer to the same date. Ignores time.
|
|
452
|
+
* @param [inputDateA] - First date to compare or the current time if null given
|
|
404
453
|
* @param inputDateB - Second date to compare
|
|
405
454
|
*/
|
|
406
|
-
declare function sameDay(inputDateA:
|
|
455
|
+
declare function sameDay(inputDateA: MaybeDateInput, inputDateB: DateInput): boolean;
|
|
407
456
|
|
|
408
457
|
/**
|
|
409
458
|
* Checks if two date objects refer to the same time seconds. Ignores date.
|
|
410
459
|
* @param inputDateA - First date to compare
|
|
460
|
+
* @param [inputDateB] - Second date to compare or the current time if nothing given
|
|
461
|
+
*/
|
|
462
|
+
declare function sameSecond(inputDateA: DateInput, inputDateB?: MaybeDateInput): boolean;
|
|
463
|
+
/**
|
|
464
|
+
* Checks if two date objects refer to the same time seconds. Ignores date.
|
|
465
|
+
* @param [inputDateA] - First date to compare or the current time if null given
|
|
466
|
+
* @param inputDateB - Second date to compare
|
|
467
|
+
*/
|
|
468
|
+
declare function sameSecond(inputDateA: MaybeDateInput, inputDateB: DateInput): boolean;
|
|
469
|
+
|
|
470
|
+
/**
|
|
471
|
+
* Checks if two date objects refer to the same millisecond. Ignores date.
|
|
472
|
+
* @param inputDateA - First date to compare
|
|
473
|
+
* @param [inputDateB] - Second date to compare or the current time if nothing given
|
|
474
|
+
*/
|
|
475
|
+
declare function sameMillisecond(inputDateA: DateInput, inputDateB?: MaybeDateInput): boolean;
|
|
476
|
+
/**
|
|
477
|
+
* Checks if two date objects refer to the same millisecond. Ignores date.
|
|
478
|
+
* @param [inputDateA] - First date to compare or the current time if null given
|
|
411
479
|
* @param inputDateB - Second date to compare
|
|
412
480
|
*/
|
|
413
|
-
declare function
|
|
481
|
+
declare function sameMillisecond(inputDateA: MaybeDateInput, inputDateB: DateInput): boolean;
|
|
414
482
|
|
|
415
483
|
/**
|
|
416
484
|
* Checks if two date objects refer to the same time minutes. Ignores date.
|
|
417
485
|
* @param inputDateA - First date to compare
|
|
486
|
+
* @param [inputDateB] - Second date to compare or the current time if nothing given
|
|
487
|
+
*/
|
|
488
|
+
declare function sameMinute(inputDateA: DateInput, inputDateB?: MaybeDateInput): boolean;
|
|
489
|
+
/**
|
|
490
|
+
* Checks if two date objects refer to the same time minutes. Ignores date.
|
|
491
|
+
* @param [inputDateA] - First date to compare or the current time if null given
|
|
418
492
|
* @param inputDateB - Second date to compare
|
|
419
493
|
*/
|
|
420
|
-
declare function sameMinute(inputDateA:
|
|
494
|
+
declare function sameMinute(inputDateA: MaybeDateInput, inputDateB: DateInput): boolean;
|
|
421
495
|
|
|
422
496
|
/**
|
|
423
497
|
* Checks if two date objects refer to the same time hour. Ignores date.
|
|
424
498
|
* @param inputDateA - First date to compare
|
|
499
|
+
* @param [inputDateB] - Second date to compare or the current time if nothing given
|
|
500
|
+
*/
|
|
501
|
+
declare function sameHour(inputDateA: DateInput, inputDateB?: MaybeDateInput): boolean;
|
|
502
|
+
/**
|
|
503
|
+
* Checks if two date objects refer to the same time hour. Ignores date.
|
|
504
|
+
* @param [inputDateA] - First date to compare or the current time if null given
|
|
425
505
|
* @param inputDateB - Second date to compare
|
|
426
506
|
*/
|
|
427
|
-
declare function sameHour(inputDateA:
|
|
507
|
+
declare function sameHour(inputDateA: MaybeDateInput, inputDateB: DateInput): boolean;
|
|
428
508
|
|
|
429
509
|
/**
|
|
430
510
|
* Checks if two date objects refer to the same year.
|
|
431
511
|
* @param inputDateA - First date to compare
|
|
512
|
+
* @param [inputDateB] - Second date to compare or the current time if null given
|
|
513
|
+
*/
|
|
514
|
+
declare function sameYear(inputDateA: DateInput, inputDateB?: MaybeDateInput): boolean;
|
|
515
|
+
/**
|
|
516
|
+
* Checks if two date objects refer to the same year.
|
|
517
|
+
* @param [inputDateA] - First date to compare or the current time if null given
|
|
432
518
|
* @param inputDateB - Second date to compare
|
|
433
519
|
*/
|
|
434
|
-
declare function sameYear(inputDateA:
|
|
520
|
+
declare function sameYear(inputDateA: MaybeDateInput, inputDateB: DateInput): boolean;
|
|
521
|
+
|
|
522
|
+
/**
|
|
523
|
+
* set the millisecond of a date object
|
|
524
|
+
* @param [inputDate] - a date or null for current time
|
|
525
|
+
* @param ms - the milliseconds you want the date set to (0 - 999) (can over/underflow)
|
|
526
|
+
*/
|
|
527
|
+
declare function setMilliseconds(inputDate: MaybeDateInput, ms: number): Date;
|
|
528
|
+
|
|
529
|
+
/**
|
|
530
|
+
* set the second of a date object
|
|
531
|
+
* @param [inputDate] - a date or null for current time
|
|
532
|
+
* @param second - the second you want the date set to (0 - 59) (can over/underflow)
|
|
533
|
+
*/
|
|
534
|
+
declare function setSeconds(inputDate: MaybeDateInput, second: number): Date;
|
|
535
|
+
|
|
536
|
+
/**
|
|
537
|
+
* set the minute of a date object
|
|
538
|
+
* @param [inputDate] - a date or null for current time
|
|
539
|
+
* @param minute - the minute you want the date set to (0 - 59) (can over/underflow)
|
|
540
|
+
*/
|
|
541
|
+
declare function setMinutes(inputDate: MaybeDateInput, minute: number): Date;
|
|
542
|
+
|
|
543
|
+
/**
|
|
544
|
+
* set the hour of a date object
|
|
545
|
+
* @param [inputDate] - a date or null for current time
|
|
546
|
+
* @param hour - the hour you want the date set to (0 - 23) (can over/underflow)
|
|
547
|
+
*/
|
|
548
|
+
declare function setHour(inputDate: MaybeDateInput, hour: number): Date;
|
|
549
|
+
|
|
550
|
+
/**
|
|
551
|
+
* set the day of the month in a date object
|
|
552
|
+
* @param [inputDate] - a date or null for current time
|
|
553
|
+
* @param day - the day of the month you want the date set to (1-28/29/30/31) (can over/underflow)
|
|
554
|
+
* @param [dateOverflow] - Whether or not to allow the date to overflow to another month if the given day isn't in the current month
|
|
555
|
+
*/
|
|
556
|
+
declare function setDayOfMonth(inputDate: MaybeDateInput, day: number, dateOverflow?: boolean): Date;
|
|
557
|
+
|
|
558
|
+
/**
|
|
559
|
+
* set the month of a date
|
|
560
|
+
* @param [inputDate] - a date or null for current time
|
|
561
|
+
* @param month - the zero-based month to set (0-11, where 0 is January) (can over/underflow)
|
|
562
|
+
* @param [dateOverflow] - Whether or not to allow the date to overflow to another month if the inputDate’s month is out of range of the new month.
|
|
563
|
+
*/
|
|
564
|
+
declare function setMonth(inputDate: MaybeDateInput, month: number, dateOverflow?: boolean): Date;
|
|
565
|
+
|
|
566
|
+
/**
|
|
567
|
+
* set the year of a date object
|
|
568
|
+
* @param inputDate - a date or null for current time
|
|
569
|
+
* @param year - the full year you want the date to be set to
|
|
570
|
+
* @param [dateOverflow] - Whether or not to allow the date to overflow to another month if the inputDate’s month is out of range of the new month.
|
|
571
|
+
*/
|
|
572
|
+
declare function setYear(inputDate: MaybeDateInput, year: number, dateOverflow?: boolean): Date;
|
|
435
573
|
|
|
436
574
|
/**
|
|
437
575
|
* Returns a Date object for the last day at the last second of the given week.
|
|
438
576
|
* Defaults to Sunday as the first day of the week:
|
|
439
577
|
* 0 = Sunday ... 6 = Saturday
|
|
440
|
-
* @param inputDate - Gets the last day of the week
|
|
441
|
-
* @param startOfWeekDay - The first day of the week
|
|
578
|
+
* @param [inputDate] - Gets the last day of the week
|
|
579
|
+
* @param [startOfWeekDay] - The first day of the week
|
|
442
580
|
*/
|
|
443
|
-
declare function weekEnd(inputDate
|
|
581
|
+
declare function weekEnd(inputDate?: MaybeDateInput, startOfWeekDay?: number): Date;
|
|
444
582
|
|
|
445
583
|
/**
|
|
446
584
|
* Returns a Date object for start of the given week. Defaults to Sunday as the
|
|
447
585
|
* first day of the week:
|
|
448
586
|
* 0 = Sunday ... 6 = Saturday
|
|
449
|
-
* @param inputDate - A string or
|
|
450
|
-
* @param startOfWeekDay - Determines which day of the week is the first
|
|
587
|
+
* @param [inputDate] - A string, Date object or nothing for current week
|
|
588
|
+
* @param [startOfWeekDay] - Determines which day of the week is the first
|
|
451
589
|
*/
|
|
452
|
-
declare function weekStart(inputDate
|
|
590
|
+
declare function weekStart(inputDate?: MaybeDateInput, startOfWeekDay?: number): Date;
|
|
453
591
|
|
|
454
592
|
/**
|
|
455
593
|
* Get the number of days in the given date’s year.
|
|
456
|
-
* @param inputDate -
|
|
594
|
+
* @param [inputDate] - A string, Date object or nothing for the current year
|
|
457
595
|
*/
|
|
458
|
-
declare function yearDays(inputDate
|
|
596
|
+
declare function yearDays(inputDate?: MaybeDateInput): number;
|
|
459
597
|
|
|
460
598
|
/**
|
|
461
599
|
* Returns a Date object for the with the input date set to the start of the current year.
|
|
462
|
-
* @param inputDate - A string or
|
|
600
|
+
* @param [inputDate] - A string, Date object or nothing for the current year
|
|
463
601
|
*/
|
|
464
|
-
declare function yearStart(inputDate
|
|
602
|
+
declare function yearStart(inputDate?: MaybeDateInput): Date;
|
|
465
603
|
|
|
466
604
|
/**
|
|
467
605
|
* Returns a Date object for the with the input date set to the end of the current year.
|
|
468
|
-
* @param inputDate - A string or
|
|
606
|
+
* @param [inputDate] - A string, Date object or nothing for the current year
|
|
469
607
|
*/
|
|
470
|
-
declare function yearEnd(inputDate
|
|
608
|
+
declare function yearEnd(inputDate?: MaybeDateInput): Date;
|
|
471
609
|
|
|
472
610
|
/**
|
|
473
|
-
* Is the first date before the second one?
|
|
611
|
+
* Is the first date before the second one or the current time?
|
|
474
612
|
*
|
|
475
613
|
* @param inputDate - The date that should be before the other one to return true
|
|
476
|
-
* @param dateToCompare - The date to compare with
|
|
614
|
+
* @param [dateToCompare] - The date to compare with or the current time if nothing given
|
|
477
615
|
*
|
|
478
|
-
* @returns The first date is before the second date.
|
|
616
|
+
* @returns The first date is before the second date or the current time.
|
|
479
617
|
*/
|
|
480
|
-
declare function isBefore(inputDate: DateInput, dateToCompare
|
|
618
|
+
declare function isBefore(inputDate: DateInput, dateToCompare?: MaybeDateInput): boolean;
|
|
481
619
|
|
|
482
620
|
/**
|
|
483
621
|
* @name isAfter
|
|
484
622
|
* @category Common Helpers
|
|
485
|
-
* @summary Is the first date after the second one?
|
|
623
|
+
* @summary Is the first date after the second one or the current time?
|
|
486
624
|
*
|
|
487
625
|
* @description
|
|
488
|
-
* Is the first date after the second one?
|
|
626
|
+
* Is the first date after the second one or the current time?
|
|
489
627
|
*
|
|
490
628
|
* @param inputDate - The date that should be after the other one to return true
|
|
491
|
-
* @param dateToCompare - The date to compare with
|
|
629
|
+
* @param [dateToCompare] - The date to compare with or the current time if nothing given
|
|
492
630
|
*
|
|
493
|
-
* @returns The first date is after the second date.
|
|
631
|
+
* @returns The first date is after the second date or the current time.
|
|
494
632
|
*/
|
|
495
|
-
declare function isAfter(inputDate: DateInput, dateToCompare
|
|
633
|
+
declare function isAfter(inputDate: DateInput, dateToCompare?: MaybeDateInput): boolean;
|
|
496
634
|
|
|
497
635
|
/**
|
|
498
|
-
* Are the given dates equal?
|
|
636
|
+
* Are the given dates equal or given date to the current time?
|
|
499
637
|
*
|
|
500
638
|
* @param dateLeft - The first date to compare
|
|
639
|
+
* @param [dateRight] - The second date to compare or the current time of nothing given
|
|
640
|
+
*
|
|
641
|
+
* @returns The dates are equal or date to the current time
|
|
642
|
+
*/
|
|
643
|
+
declare function isEqual(dateLeft: DateInput, dateRight?: MaybeDateInput): boolean;
|
|
644
|
+
/**
|
|
645
|
+
* Are the given dates equal or given date to the current time?
|
|
646
|
+
*
|
|
647
|
+
* @param [dateLeft] - The first date to compare or the current time if null given
|
|
501
648
|
* @param dateRight - The second date to compare
|
|
502
649
|
*
|
|
503
|
-
* @returns The dates are equal
|
|
650
|
+
* @returns The dates are equal or date to the current time
|
|
651
|
+
*/
|
|
652
|
+
declare function isEqual(dateLeft: MaybeDateInput, dateRight: DateInput): boolean;
|
|
653
|
+
|
|
654
|
+
/**
|
|
655
|
+
* is the date in the past compared to the current time
|
|
656
|
+
* @param inputDate - The date that should be in the past
|
|
657
|
+
* @returns the given date is in the past compared to the current time
|
|
658
|
+
*/
|
|
659
|
+
declare function isPast(inputDate: DateInput): boolean;
|
|
660
|
+
|
|
661
|
+
/**
|
|
662
|
+
* is the date in the future compared to the current time
|
|
663
|
+
* @param inputDate - The date that should be in the future
|
|
664
|
+
* @returns the given date is in the future compared to the current time
|
|
504
665
|
*/
|
|
505
|
-
declare function
|
|
666
|
+
declare function isFuture(inputDate: DateInput): boolean;
|
|
506
667
|
|
|
507
668
|
/**
|
|
508
669
|
* Returns the difference between 2 dates in milliseconds.
|
|
509
|
-
* @param dateA A date to compare with the right date
|
|
510
|
-
* @param dateB A date to compare with the left date
|
|
670
|
+
* @param dateA - A date to compare with the right date
|
|
671
|
+
* @param [dateB] - A date to compare with the left date or nothing to compare with the current time
|
|
511
672
|
*/
|
|
512
|
-
declare function diffMilliseconds(dateA: DateInput, dateB
|
|
673
|
+
declare function diffMilliseconds(dateA: DateInput, dateB?: MaybeDateInput): number;
|
|
674
|
+
/**
|
|
675
|
+
* Returns the difference between 2 dates in milliseconds.
|
|
676
|
+
* @param [dateA] - A date to compare with the right date or null to compare with the current time
|
|
677
|
+
* @param dateB - A date to compare with the left date
|
|
678
|
+
*/
|
|
679
|
+
declare function diffMilliseconds(dateA: MaybeDateInput, dateB: DateInput): number;
|
|
513
680
|
|
|
514
681
|
type DiffRoundingMethod = "trunc" | "round" | "floor" | "ceil";
|
|
515
682
|
|
|
516
683
|
/**
|
|
517
684
|
* Returns the difference between 2 dates in seconds.
|
|
518
|
-
* @param dateA A date to compare with the right date
|
|
519
|
-
* @param dateB A date to compare with the left date
|
|
520
|
-
* @param roundingMethod the rounding method to use, default: trunc
|
|
685
|
+
* @param dateA - A date to compare with the right date
|
|
686
|
+
* @param [dateB] - A date to compare with the left date or nothing to compare with the current time.
|
|
687
|
+
* @param [roundingMethod] - the rounding method to use, default: trunc
|
|
521
688
|
*/
|
|
522
|
-
declare function diffSeconds(dateA: DateInput, dateB
|
|
689
|
+
declare function diffSeconds(dateA: DateInput, dateB?: MaybeDateInput, roundingMethod?: DiffRoundingMethod): number;
|
|
690
|
+
/**
|
|
691
|
+
* Returns the difference between 2 dates in seconds.
|
|
692
|
+
* @param [dateA] - A date to compare with the right date or null to compare with the current time
|
|
693
|
+
* @param dateB - A date to compare with the left date
|
|
694
|
+
* @param [roundingMethod] - the rounding method to use, default: trunc
|
|
695
|
+
*/
|
|
696
|
+
declare function diffSeconds(dateA: MaybeDateInput, dateB: DateInput, roundingMethod?: DiffRoundingMethod): number;
|
|
523
697
|
|
|
524
698
|
/**
|
|
525
699
|
* Returns the difference between 2 dates in minutes.
|
|
526
|
-
* @param dateA A date to compare with the right date
|
|
527
|
-
* @param
|
|
700
|
+
* @param dateA - A date to compare with the right date
|
|
701
|
+
* @param [dateB] - A Date to compare with the left date or nothing to compare with the current time
|
|
702
|
+
* @param [roundingMethod] the rounding method to use, default: trunc
|
|
703
|
+
*/
|
|
704
|
+
declare function diffMinutes(dateA: DateInput, dateB?: MaybeDateInput, roundingMethod?: DiffRoundingMethod): number;
|
|
705
|
+
/**
|
|
706
|
+
* Returns the difference between 2 dates in minutes.
|
|
707
|
+
* @param [dateA] - A date to compare with the right date or null to compare with the current time
|
|
708
|
+
* @param dateB - A Date to compare with the left date
|
|
709
|
+
* @param [roundingMethod] the rounding method to use, default: trunc
|
|
528
710
|
*/
|
|
529
711
|
declare function diffMinutes(dateA: DateInput, dateB: DateInput, roundingMethod?: DiffRoundingMethod): number;
|
|
530
712
|
|
|
531
713
|
/**
|
|
532
714
|
* Returns the difference between 2 dates in hours.
|
|
533
|
-
* @param dateA A date to compare with the right date
|
|
534
|
-
* @param dateB A date to compare with the left date
|
|
535
|
-
* @param roundingMethod the rounding method to use, default: trunc
|
|
715
|
+
* @param dateA - A date to compare with the right date
|
|
716
|
+
* @param [dateB] - A date to compare with the left date or nothing to compare with the current time
|
|
717
|
+
* @param [roundingMethod] - the rounding method to use, default: trunc
|
|
718
|
+
*/
|
|
719
|
+
declare function diffHours(dateA: DateInput, dateB?: MaybeDateInput, roundingMethod?: DiffRoundingMethod): number;
|
|
720
|
+
/**
|
|
721
|
+
* Returns the difference between 2 dates in hours.
|
|
722
|
+
* @param [dateA] - A date to compare with the right date or null to compare with the current time
|
|
723
|
+
* @param dateB - A date to compare with the left date
|
|
724
|
+
* @param [roundingMethod] - the rounding method to use, default: trunc
|
|
536
725
|
*/
|
|
537
|
-
declare function diffHours(dateA:
|
|
726
|
+
declare function diffHours(dateA: MaybeDateInput, dateB: DateInput, roundingMethod?: DiffRoundingMethod): number;
|
|
538
727
|
|
|
539
728
|
/**
|
|
540
729
|
* Returns the difference between 2 dates in days.
|
|
541
|
-
* @param dateA A date to compare with the right date
|
|
542
|
-
* @param dateB A date to compare with the left date
|
|
543
|
-
* @param roundingMethod the rounding method to use, default: trunc
|
|
730
|
+
* @param dateA - A date to compare with the right date
|
|
731
|
+
* @param [dateB] - A date to compare with the left date or nothing to compare with the current time
|
|
732
|
+
* @param [roundingMethod] - the rounding method to use, default: trunc
|
|
733
|
+
*/
|
|
734
|
+
declare function diffDays(dateA: DateInput, dateB?: MaybeDateInput, roundingMethod?: DiffRoundingMethod): number;
|
|
735
|
+
/**
|
|
736
|
+
* Returns the difference between 2 dates in days.
|
|
737
|
+
* @param [dateA] - A date to compare with the right date or null to compare with the current time
|
|
738
|
+
* @param dateB - A date to compare with the left date
|
|
739
|
+
* @param [roundingMethod] - the rounding method to use, default: trunc
|
|
544
740
|
*/
|
|
545
|
-
declare function diffDays(dateA:
|
|
741
|
+
declare function diffDays(dateA: MaybeDateInput, dateB: DateInput, roundingMethod?: DiffRoundingMethod): number;
|
|
546
742
|
|
|
547
743
|
/**
|
|
548
744
|
* Returns the difference between 2 dates in days.
|
|
549
|
-
* @param dateA A date to compare with the right date
|
|
550
|
-
* @param dateB A date to compare with the left date
|
|
551
|
-
* @param roundingMethod the rounding method to use, default: trunc
|
|
745
|
+
* @param dateA - A date to compare with the right date
|
|
746
|
+
* @param [dateB] - A date to compare with the left date or nothing to compare with the current time
|
|
747
|
+
* @param [roundingMethod] - the rounding method to use, default: trunc
|
|
748
|
+
*/
|
|
749
|
+
declare function diffWeeks(dateA: DateInput, dateB: DateInput, roundingMethod?: DiffRoundingMethod): number;
|
|
750
|
+
/**
|
|
751
|
+
* Returns the difference between 2 dates in days.
|
|
752
|
+
* @param [dateA] - A date to compare with the right date or null to compare with the current time
|
|
753
|
+
* @param dateB - A date to compare with the left date
|
|
754
|
+
* @param [roundingMethod] - the rounding method to use, default: trunc
|
|
552
755
|
*/
|
|
553
756
|
declare function diffWeeks(dateA: DateInput, dateB: DateInput, roundingMethod?: DiffRoundingMethod): number;
|
|
554
757
|
|
|
555
758
|
/**
|
|
556
759
|
* Returns the difference between 2 dates in months.
|
|
557
|
-
* @param dateA A date to compare with the dateB date
|
|
558
|
-
* @param dateB A date to compare with the dateA date
|
|
760
|
+
* @param dateA - A date to compare with the dateB date
|
|
761
|
+
* @param [dateB] - A date to compare with the dateA date or nothing to compare with the current time
|
|
762
|
+
*/
|
|
763
|
+
declare function diffMonths(dateA: DateInput, dateB?: MaybeDateInput): number;
|
|
764
|
+
/**
|
|
765
|
+
* Returns the difference between 2 dates in months.
|
|
766
|
+
* @param [dateA] - A date to compare with the dateB date or null to compare with the current time
|
|
767
|
+
* @param dateB - A date to compare with the dateA date
|
|
559
768
|
*/
|
|
560
|
-
declare function diffMonths(dateA:
|
|
769
|
+
declare function diffMonths(dateA: MaybeDateInput, dateB: DateInput): number;
|
|
561
770
|
|
|
562
771
|
/**
|
|
563
772
|
* Returns the difference between 2 dates in years.
|
|
564
|
-
* @param dateA A date to compare with the dateB date
|
|
565
|
-
* @param dateB A date to compare with the dateA date
|
|
773
|
+
* @param dateA - A date to compare with the dateB date
|
|
774
|
+
* @param [dateB] - A date to compare with the dateA date or nothing to compare with the current time
|
|
775
|
+
*/
|
|
776
|
+
declare function diffYears(dateA: DateInput, dateB?: MaybeDateInput): number;
|
|
777
|
+
/**
|
|
778
|
+
* Returns the difference between 2 dates in years.
|
|
779
|
+
* @param [dateA] - A date to compare with the dateB date or null to compare with the current time
|
|
780
|
+
* @param dateB - A date to compare with the dateA date
|
|
781
|
+
*/
|
|
782
|
+
declare function diffYears(dateA: MaybeDateInput, dateB: DateInput): number;
|
|
783
|
+
|
|
784
|
+
type DurationKey = keyof Duration;
|
|
785
|
+
/**
|
|
786
|
+
* Options for `diff` function
|
|
787
|
+
*/
|
|
788
|
+
interface DiffOptions {
|
|
789
|
+
/**
|
|
790
|
+
* whether the difference should be absolute (not negative)
|
|
791
|
+
*/
|
|
792
|
+
abs?: boolean;
|
|
793
|
+
/**
|
|
794
|
+
* units you want to skip, for example weeks
|
|
795
|
+
*/
|
|
796
|
+
skip?: DurationKey[] | Set<DurationKey>;
|
|
797
|
+
}
|
|
798
|
+
/**
|
|
799
|
+
* Returns the difference between 2 dates in an object
|
|
800
|
+
* @param dateA - A date to compare with the right date
|
|
801
|
+
* @param [dateB] - A date to compare with the left date or nothing to compare with the current time
|
|
802
|
+
* @param [options] additional options
|
|
803
|
+
* @param [options.skip] units you want skip
|
|
804
|
+
* @param [options.abs] whether the difference should be absolute
|
|
805
|
+
* @returns an object which could be used with `Intl.DurationFormat.format'`
|
|
806
|
+
*/
|
|
807
|
+
declare function diff(dateA: DateInput, dateB?: MaybeDateInput, options?: DiffOptions): Duration;
|
|
808
|
+
/**
|
|
809
|
+
* Returns the difference between 2 dates in an object
|
|
810
|
+
* @param [dateA] - A date to compare with the right date or null to compare with the current time
|
|
811
|
+
* @param dateB - A date to compare with the left date
|
|
812
|
+
* @param [options] additional options
|
|
813
|
+
* @param [options.skip] units you want skip
|
|
814
|
+
* @param [options.abs] whether the difference should be absolute
|
|
815
|
+
* @returns an object which could be used with `Intl.DurationFormat.format'`
|
|
566
816
|
*/
|
|
567
|
-
declare function
|
|
817
|
+
declare function diff(dateA: MaybeDateInput, dateB: DateInput, options?: DiffOptions): Duration;
|
|
568
818
|
|
|
569
|
-
export { type DateInput, type FilledPart, type Format, type FormatOptions, type FormatPattern, type FormatStyle, type FormatStyleObj, type FormatToken, type NamedFormatOption, type NamedFormats, type ParseOptions, type Part, addDay, addHour, addMinute, addMonth, addSecond, addYear, ap, applyOffset, date, dayEnd, dayOfYear, dayStart, diffDays, diffHours, diffMilliseconds, diffMinutes, diffMonths, diffSeconds, diffWeeks, diffYears, format, formatStr, fourDigitYear, hourEnd, hourStart, isAfter, isBefore, isEqual, iso8601, minuteEnd, minuteStart, monthDays, monthEnd, monthStart, nearestDay, offset, parse, parseParts, parts, range, removeOffset, sameDay, sameHour, sameMinute, sameSecond, sameYear, tzDate, weekEnd, weekStart, yearDays, yearEnd, yearStart };
|
|
819
|
+
export { type DateInput, type DiffOptions, type Duration, type DurationObj, type ExtendedPartTypes, type FilledPart, type Format, type FormatOptions, type FormatPattern, type FormatStyle, type FormatStyleObj, type FormatToken, type MaybeDateInput, type NamedFormatOption, type NamedFormats, type ParseOptions, type Part, add, addDay, addHour, addMillisecond, addMinute, addMonth, addSecond, addYear, ap, applyOffset, date, dayEnd, dayOfYear, dayStart, diff, diffDays, diffHours, diffMilliseconds, diffMinutes, diffMonths, diffSeconds, diffWeeks, diffYears, format, formatStr, fourDigitYear, hourEnd, hourStart, isAfter, isBefore, isEqual, isFuture, isPast, iso8601, minuteEnd, minuteStart, monthDays, monthEnd, monthStart, nearestDay, offset, parse, parseParts, parts, range, removeOffset, sameDay, sameHour, sameMillisecond, sameMinute, sameSecond, sameYear, setDayOfMonth, setHour, setMilliseconds, setMinutes, setMonth, setSeconds, setYear, tzDate, weekEnd, weekStart, yearDays, yearEnd, yearStart };
|