1 | import {
|
2 | CalendarSystem,
|
3 | DateTimeFormatOptions,
|
4 | NumberingSystem,
|
5 | StringUnitLength,
|
6 | ToISOFormat,
|
7 | ToISOTimeDurationOptions,
|
8 | ZoneOptions,
|
9 | } from '../index';
|
10 | import { Zone } from './zone';
|
11 | import { Duration, DurationLike, DurationUnits } from './duration';
|
12 | import { Interval } from './interval';
|
13 |
|
14 | export type DateTimeUnit = 'year' | 'quarter' | 'month' | 'week' | 'day' | 'hour' | 'minute' | 'second' | 'millisecond';
|
15 | export type ToRelativeUnit = 'years' | 'quarters' | 'months' | 'weeks' | 'days' | 'hours' | 'minutes' | 'seconds';
|
16 |
|
17 | export type MonthNumbers = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
|
18 | export type WeekdayNumbers = 1 | 2 | 3 | 4 | 5 | 6 | 7;
|
19 |
|
20 | export type DayNumbers =
|
21 | | 1
|
22 | | 2
|
23 | | 3
|
24 | | 4
|
25 | | 5
|
26 | | 6
|
27 | | 7
|
28 | | 8
|
29 | | 9
|
30 | | 10
|
31 | | 11
|
32 | | 12
|
33 | | 13
|
34 | | 14
|
35 | | 15
|
36 | | 16
|
37 | | 17
|
38 | | 18
|
39 | | 19
|
40 | | 20
|
41 | | 21
|
42 | | 22
|
43 | | 23
|
44 | | 24
|
45 | | 25
|
46 | | 26
|
47 | | 27
|
48 | | 28
|
49 | | 29
|
50 | | 30
|
51 | | 31;
|
52 |
|
53 | export type SecondNumbers =
|
54 | | 0
|
55 | | 1
|
56 | | 2
|
57 | | 3
|
58 | | 4
|
59 | | 5
|
60 | | 6
|
61 | | 7
|
62 | | 8
|
63 | | 9
|
64 | | 10
|
65 | | 11
|
66 | | 12
|
67 | | 13
|
68 | | 14
|
69 | | 15
|
70 | | 16
|
71 | | 17
|
72 | | 18
|
73 | | 19
|
74 | | 20
|
75 | | 21
|
76 | | 22
|
77 | | 23
|
78 | | 24
|
79 | | 25
|
80 | | 26
|
81 | | 27
|
82 | | 28
|
83 | | 29
|
84 | | 30
|
85 | | 31
|
86 | | 32
|
87 | | 33
|
88 | | 34
|
89 | | 35
|
90 | | 36
|
91 | | 37
|
92 | | 38
|
93 | | 39
|
94 | | 40
|
95 | | 41
|
96 | | 42
|
97 | | 43
|
98 | | 44
|
99 | | 45
|
100 | | 46
|
101 | | 47
|
102 | | 48
|
103 | | 49
|
104 | | 50
|
105 | | 51
|
106 | | 52
|
107 | | 53
|
108 | | 54
|
109 | | 55
|
110 | | 56
|
111 | | 57
|
112 | | 58
|
113 | | 59;
|
114 |
|
115 | export type MinuteNumbers = SecondNumbers;
|
116 |
|
117 | export type HourNumbers =
|
118 | | 0
|
119 | | 1
|
120 | | 2
|
121 | | 3
|
122 | | 4
|
123 | | 5
|
124 | | 6
|
125 | | 7
|
126 | | 8
|
127 | | 9
|
128 | | 10
|
129 | | 11
|
130 | | 12
|
131 | | 13
|
132 | | 14
|
133 | | 15
|
134 | | 16
|
135 | | 17
|
136 | | 18
|
137 | | 19
|
138 | | 20
|
139 | | 21
|
140 | | 22
|
141 | | 23;
|
142 |
|
143 | export type WeekNumbers =
|
144 | | 1
|
145 | | 2
|
146 | | 3
|
147 | | 4
|
148 | | 5
|
149 | | 6
|
150 | | 7
|
151 | | 8
|
152 | | 9
|
153 | | 10
|
154 | | 11
|
155 | | 12
|
156 | | 13
|
157 | | 14
|
158 | | 15
|
159 | | 16
|
160 | | 17
|
161 | | 18
|
162 | | 19
|
163 | | 20
|
164 | | 21
|
165 | | 22
|
166 | | 23
|
167 | | 24
|
168 | | 25
|
169 | | 26
|
170 | | 27
|
171 | | 28
|
172 | | 29
|
173 | | 30
|
174 | | 31
|
175 | | 32
|
176 | | 33
|
177 | | 34
|
178 | | 35
|
179 | | 36
|
180 | | 37
|
181 | | 38
|
182 | | 39
|
183 | | 40
|
184 | | 41
|
185 | | 42
|
186 | | 43
|
187 | | 44
|
188 | | 45
|
189 | | 46
|
190 | | 47
|
191 | | 48
|
192 | | 49
|
193 | | 50
|
194 | | 51
|
195 | | 52
|
196 | | 53;
|
197 |
|
198 | export type QuarterNumbers = 1 | 2 | 3 | 4;
|
199 |
|
200 | export type PossibleDaysInMonth = 28 | 29 | 30 | 31;
|
201 | export type PossibleDaysInYear = 365 | 366;
|
202 | export type PossibleWeeksInYear = 52 | 53;
|
203 |
|
204 | export interface ToObjectOutput extends DateTimeJSOptions {
|
205 | year: number;
|
206 | month: number;
|
207 | day: number;
|
208 | hour: number;
|
209 | minute: number;
|
210 | second: number;
|
211 | millisecond: number;
|
212 | }
|
213 |
|
214 | export interface ToRelativeOptions extends Omit<ToRelativeCalendarOptions, 'unit'> {
|
215 | /**
|
216 | * @default long
|
217 | */
|
218 | style?: StringUnitLength | undefined;
|
219 | /** @default true */
|
220 | round?: boolean | undefined;
|
221 | /**
|
222 | * Padding in milliseconds. This allows you to round up the result if it fits inside the threshold.
|
223 | * Don't use in combination with {round: false} because the decimal output will include the padding.
|
224 | * @default 0
|
225 | */
|
226 | padding?: number | undefined;
|
227 | /**
|
228 | * A single unit or an array of units. If an array is supplied, the method will pick the best one
|
229 | * to use from the array. If omitted, the method will pick the unit from a default set.
|
230 | */
|
231 | unit?: ToRelativeUnit | ToRelativeUnit[] | undefined;
|
232 | }
|
233 |
|
234 | export interface ToRelativeCalendarOptions {
|
235 | /**
|
236 | * The DateTime to use as the basis to which this time is compared
|
237 | * @default now
|
238 | */
|
239 | base?: DateTime | undefined;
|
240 | /**
|
241 | * Override the locale of this DateTime
|
242 | */
|
243 | locale?: string | undefined;
|
244 | /** If omitted, the method will pick the unit. */
|
245 | unit?: ToRelativeUnit | undefined;
|
246 | /**
|
247 | * Override the numberingSystem of this DateTime.
|
248 | * The Intl system may choose not to honor this.
|
249 | */
|
250 | numberingSystem?: NumberingSystem | undefined;
|
251 | }
|
252 |
|
253 | export interface ToSQLOptions {
|
254 | /**
|
255 | * Include the offset, such as 'Z' or '-04:00'
|
256 | * @default true
|
257 | */
|
258 | includeOffset?: boolean | undefined;
|
259 | /**
|
260 | * Include the zone, such as 'America/New_York'. Overrides includeOffset.
|
261 | * @default false
|
262 | */
|
263 | includeZone?: boolean | undefined;
|
264 | /**
|
265 | * include the space between the time and the offset, such as '05:15:16.345 -04:00'
|
266 | * @default true
|
267 | */
|
268 | includeOffsetSpace?: boolean;
|
269 | }
|
270 |
|
271 | export interface ToISODateOptions {
|
272 | /**
|
273 | * Choose between the basic and extended format
|
274 | * @default 'extended'
|
275 | */
|
276 | format?: ToISOFormat | undefined;
|
277 | }
|
278 |
|
279 | export interface ToISOTimeOptions extends ToISOTimeDurationOptions {
|
280 | /**
|
281 | * Include the offset, such as 'Z' or '-04:00'
|
282 | * @default true
|
283 | */
|
284 | includeOffset?: boolean | undefined;
|
285 |
|
286 | /**
|
287 | * add the time zone format extension
|
288 | * @default false
|
289 | */
|
290 | extendedZone?: boolean | undefined;
|
291 | }
|
292 |
|
293 | /** @deprecated alias for backwards compatibility */
|
294 | export type ISOTimeOptions = ToISOTimeOptions;
|
295 |
|
296 | export interface LocaleOptions {
|
297 | /**
|
298 | * @default system's locale
|
299 | */
|
300 | locale?: string | undefined;
|
301 | outputCalendar?: CalendarSystem | undefined;
|
302 | numberingSystem?: NumberingSystem | undefined;
|
303 | }
|
304 |
|
305 | export type ResolvedLocaleOptions = Required<LocaleOptions>;
|
306 |
|
307 | export interface DateTimeOptions extends LocaleOptions {
|
308 | /**
|
309 | * Use this zone if no offset is specified in the input string itself. Will also convert the time to this zone.
|
310 | * @default local
|
311 | */
|
312 | zone?: string | Zone | undefined;
|
313 | /**
|
314 | * Override the zone with a fixed-offset zone specified in the string itself, if it specifies one.
|
315 | * @default false
|
316 | */
|
317 | setZone?: boolean | undefined;
|
318 | }
|
319 |
|
320 | export type DateTimeJSOptions = Omit<DateTimeOptions, 'setZone'>;
|
321 |
|
322 | export interface DateObjectUnits {
|
323 | // a year, such as 1987
|
324 | year?: number | undefined;
|
325 | // a month, 1-12
|
326 | month?: number | undefined;
|
327 | // a day of the month, 1-31, depending on the month
|
328 | day?: number | undefined;
|
329 | // day of the year, 1-365 or 366
|
330 | ordinal?: number | undefined;
|
331 | // an ISO week year
|
332 | weekYear?: number | undefined;
|
333 | // an ISO week number, between 1 and 52 or 53, depending on the year
|
334 | weekNumber?: number | undefined;
|
335 | // an ISO weekday, 1-7, where 1 is Monday and 7 is Sunday
|
336 | weekday?: number | undefined;
|
337 | // hour of the day, 0-23
|
338 | hour?: number | undefined;
|
339 | // minute of the hour, 0-59
|
340 | minute?: number | undefined;
|
341 | // second of the minute, 0-59
|
342 | second?: number | undefined;
|
343 | // millisecond of the second, 0-999
|
344 | millisecond?: number | undefined;
|
345 | }
|
346 |
|
347 | export type ConversionAccuracy = 'casual' | 'longterm';
|
348 |
|
349 | /**
|
350 | * @deprecated You should use Intl.DateTimeFormatOptions' fields and values instead.
|
351 | */
|
352 | export type DateTimeFormatPresetValue = 'numeric' | 'short' | 'long';
|
353 | /**
|
354 | * @deprecated Use Intl.DateTimeFormatOptions instead.
|
355 | */
|
356 | export type DateTimeFormatPreset = Intl.DateTimeFormatOptions;
|
357 |
|
358 | export interface DiffOptions {
|
359 | conversionAccuracy?: ConversionAccuracy | undefined;
|
360 | }
|
361 |
|
362 | export interface ExplainedFormat {
|
363 | input: string;
|
364 | tokens: Array<{ literal: boolean; val: string }>;
|
365 | regex?: RegExp | undefined;
|
366 | rawMatches?: RegExpMatchArray | null | undefined;
|
367 | matches?: { [k: string]: any } | undefined;
|
368 | result?: { [k: string]: any } | null | undefined;
|
369 | zone?: Zone | null | undefined;
|
370 | invalidReason?: string | undefined;
|
371 | }
|
372 |
|
373 | /**
|
374 | * A DateTime is an immutable data structure representing a specific date and time and accompanying methods.
|
375 | * It contains class and instance methods for creating, parsing, interrogating, transforming, and formatting them.
|
376 | *
|
377 | * A DateTime comprises of:
|
378 | * * A timestamp. Each DateTime instance refers to a specific millisecond of the Unix epoch.
|
379 | * * A time zone. Each instance is considered in the context of a specific zone (by default the local system's zone).
|
380 | * * Configuration properties that effect how output strings are formatted, such as `locale`, `numberingSystem`, and `outputCalendar`.
|
381 | *
|
382 | * Here is a brief overview of the most commonly used functionality it provides:
|
383 | *
|
384 | * * **Creation**: To create a DateTime from its components, use one of its factory class methods: {@link DateTime.local}, {@link DateTime.utc}, and (most flexibly) {@link DateTime.fromObject}.
|
385 | * To create one from a standard string format, use {@link DateTime.fromISO}, {@link DateTime.fromHTTP}, and {@link DateTime.fromRFC2822}.
|
386 | * To create one from a custom string format, use {@link DateTime.fromFormat}. To create one from a native JS date, use {@link DateTime.fromJSDate}.
|
387 | * * **Gregorian calendar and time**: To examine the Gregorian properties of a DateTime individually (i.e as opposed to collectively through {@link DateTime#toObject}), use the {@link DateTime#year},
|
388 | * {@link DateTime#month}, {@link DateTime#day}, {@link DateTime#hour}, {@link DateTime#minute}, {@link DateTime#second}, {@link DateTime#millisecond} accessors.
|
389 | * * **Week calendar**: For ISO week calendar attributes, see the {@link DateTime#weekYear}, {@link DateTime#weekNumber}, and {@link DateTime#weekday} accessors.
|
390 | * * **Configuration** See the {@link DateTime#locale} and {@link DateTime#numberingSystem} accessors.
|
391 | * * **Transformation**: To transform the DateTime into other DateTimes, use {@link DateTime#set}, {@link DateTime#reconfigure}, {@link DateTime#setZone}, {@link DateTime#setLocale},
|
392 | * {@link DateTime.plus}, {@link DateTime#minus}, {@link DateTime#endOf}, {@link DateTime#startOf}, {@link DateTime#toUTC}, and {@link DateTime#toLocal}.
|
393 | * * **Output**: To convert the DateTime to other representations, use the {@link DateTime#toRelative}, {@link DateTime#toRelativeCalendar}, {@link DateTime#toJSON}, {@link DateTime#toISO},
|
394 | * {@link DateTime#toHTTP}, {@link DateTime#toObject}, {@link DateTime#toRFC2822}, {@link DateTime#toString}, {@link DateTime#toLocaleString}, {@link DateTime#toFormat},
|
395 | * {@link DateTime#toMillis} and {@link DateTime#toJSDate}.
|
396 | *
|
397 | * There's plenty others documented below. In addition, for more information on subtler topics
|
398 | * like internationalization, time zones, alternative calendars, validity, and so on, see the external documentation.
|
399 | */
|
400 | export class DateTime {
|
401 | /**
|
402 | * Create a DateTime for the current instant, in the system's time zone.
|
403 | *
|
404 | * Use Settings to override these default values if needed.
|
405 | * @example
|
406 | * DateTime.now().toISO() //~> now in the ISO format
|
407 | */
|
408 | static now(): DateTime;
|
409 |
|
410 | /**
|
411 | * Create a local DateTime
|
412 | *
|
413 | * @param year - The calendar year. If omitted (as in, call `local()` with no arguments), the current time will be used
|
414 | * @param month - The month, 1-indexed
|
415 | * @param day - The day of the month, 1-indexed
|
416 | * @param hour - The hour of the day, in 24-hour time
|
417 | * @param minute - The minute of the hour, meaning a number between 0 and 59
|
418 | * @param second - The second of the minute, meaning a number between 0 and 59
|
419 | * @param millisecond - The millisecond of the second, meaning a number between 0 and 999
|
420 | *
|
421 | * @example
|
422 | * DateTime.local() //~> now
|
423 | * @example
|
424 | * DateTime.local({ zone: "America/New_York" }) //~> now, in US east coast time
|
425 | * @example
|
426 | * DateTime.local(2017) //~> 2017-01-01T00:00:00
|
427 | * @example
|
428 | * DateTime.local(2017, 3) //~> 2017-03-01T00:00:00
|
429 | * @example
|
430 | * DateTime.local(2017, 3, 12, { locale: "fr") //~> 2017-03-12T00:00:00, with a French locale
|
431 | * @example
|
432 | * DateTime.local(2017, 3, 12, 5) //~> 2017-03-12T05:00:00
|
433 | * @example
|
434 | * DateTime.local(2017, 3, 12, 5, { zone: "utc" }) //~> 2017-03-12T05:00:00, in UTC
|
435 | * @example
|
436 | * DateTime.local(2017, 3, 12, 5, 45) //~> 2017-03-12T05:45:00
|
437 | * @example
|
438 | * DateTime.local(2017, 3, 12, 5, 45, 10) //~> 2017-03-12T05:45:10
|
439 | * @example
|
440 | * DateTime.local(2017, 3, 12, 5, 45, 10, 765) //~> 2017-03-12T05:45:10.765
|
441 | */
|
442 | static local(
|
443 | year: number,
|
444 | month: number,
|
445 | day: number,
|
446 | hour: number,
|
447 | minute: number,
|
448 | second: number,
|
449 | millisecond: number,
|
450 | opts?: DateTimeJSOptions,
|
451 | ): DateTime;
|
452 | static local(
|
453 | year: number,
|
454 | month: number,
|
455 | day: number,
|
456 | hour: number,
|
457 | minute: number,
|
458 | second: number,
|
459 | opts?: DateTimeJSOptions,
|
460 | ): DateTime;
|
461 | static local(
|
462 | year: number,
|
463 | month: number,
|
464 | day: number,
|
465 | hour: number,
|
466 | minute: number,
|
467 | opts?: DateTimeJSOptions,
|
468 | ): DateTime;
|
469 | static local(year: number, month: number, day: number, hour: number, opts?: DateTimeJSOptions): DateTime;
|
470 | static local(year: number, month: number, day: number, opts?: DateTimeJSOptions): DateTime;
|
471 | static local(year: number, month: number, opts?: DateTimeJSOptions): DateTime;
|
472 | static local(year: number, opts?: DateTimeJSOptions): DateTime;
|
473 | static local(opts?: DateTimeJSOptions): DateTime;
|
474 |
|
475 | /**
|
476 | * Create a DateTime in UTC
|
477 | *
|
478 | * @param year - The calendar year. If omitted (as in, call `utc()` with no arguments), the current time will be used
|
479 | * @param month - The month, 1-indexed
|
480 | * @param day - The day of the month
|
481 | * @param hour - The hour of the day, in 24-hour time
|
482 | * @param minute - The minute of the hour, meaning a number between 0 and 59
|
483 | * @param second - The second of the minute, meaning a number between 0 and 59
|
484 | * @param millisecond - The millisecond of the second, meaning a number between 0 and 999
|
485 | * @param options - configuration options for the DateTime
|
486 | * @param options.locale - a locale to set on the resulting DateTime instance
|
487 | * @param options.outputCalendar - the output calendar to set on the resulting DateTime instance
|
488 | * @param options.numberingSystem - the numbering system to set on the resulting DateTime instance
|
489 | *
|
490 | * @example
|
491 | * DateTime.utc() //~> now
|
492 | * @example
|
493 | * DateTime.utc(2017) //~> 2017-01-01T00:00:00Z
|
494 | * @example
|
495 | * DateTime.utc(2017, 3) //~> 2017-03-01T00:00:00Z
|
496 | * @example
|
497 | * DateTime.utc(2017, 3, 12) //~> 2017-03-12T00:00:00Z
|
498 | * @example
|
499 | * DateTime.utc(2017, 3, 12, 5) //~> 2017-03-12T05:00:00Z
|
500 | * @example
|
501 | * DateTime.utc(2017, 3, 12, 5, 45) //~> 2017-03-12T05:45:00Z
|
502 | * @example
|
503 | * DateTime.utc(2017, 3, 12, 5, 45, { locale: "fr" } ) //~> 2017-03-12T05:45:00Z with a French locale
|
504 | * @example
|
505 | * DateTime.utc(2017, 3, 12, 5, 45, 10) //~> 2017-03-12T05:45:10Z
|
506 | * @example
|
507 | * DateTime.utc(2017, 3, 12, 5, 45, 10, 765, { locale: "fr") //~> 2017-03-12T05:45:10.765Z with a French locale
|
508 | */
|
509 | static utc(
|
510 | year: number,
|
511 | month: number,
|
512 | day: number,
|
513 | hour: number,
|
514 | minute: number,
|
515 | second: number,
|
516 | millisecond: number,
|
517 | options?: LocaleOptions,
|
518 | ): DateTime;
|
519 | static utc(
|
520 | year: number,
|
521 | month: number,
|
522 | day: number,
|
523 | hour: number,
|
524 | minute: number,
|
525 | second: number,
|
526 | options?: LocaleOptions,
|
527 | ): DateTime;
|
528 | static utc(
|
529 | year: number,
|
530 | month: number,
|
531 | day: number,
|
532 | hour: number,
|
533 | minute: number,
|
534 | options?: LocaleOptions,
|
535 | ): DateTime;
|
536 | static utc(year: number, month: number, day: number, hour: number, options?: LocaleOptions): DateTime;
|
537 | static utc(year: number, month: number, day: number, options?: LocaleOptions): DateTime;
|
538 | static utc(year: number, month: number, options?: LocaleOptions): DateTime;
|
539 | static utc(year: number, options?: LocaleOptions): DateTime;
|
540 | static utc(options?: LocaleOptions): DateTime;
|
541 |
|
542 | /**
|
543 | * Create a DateTime from a JavaScript Date object. Uses the default zone.
|
544 | *
|
545 | * @param date - a JavaScript Date object
|
546 | * @param options - configuration options for the DateTime
|
547 | * @param options.zone - the zone to place the DateTime into
|
548 | */
|
549 | static fromJSDate(date: Date, options?: { zone?: string | Zone }): DateTime;
|
550 |
|
551 | /**
|
552 | * Create a DateTime from a number of milliseconds since the epoch (meaning since 1 January 1970 00:00:00 UTC). Uses the default zone.
|
553 | *
|
554 | * @param milliseconds - a number of milliseconds since 1970 UTC
|
555 | * @param options - configuration options for the DateTime
|
556 | * @param options.zone - the zone to place the DateTime into. Defaults to 'local'.
|
557 | * @param options.locale - a locale to set on the resulting DateTime instance
|
558 | * @param options.outputCalendar - the output calendar to set on the resulting DateTime instance
|
559 | * @param options.numberingSystem - the numbering system to set on the resulting DateTime instance
|
560 | */
|
561 | static fromMillis(milliseconds: number, options?: DateTimeJSOptions): DateTime;
|
562 |
|
563 | /**
|
564 | * Create a DateTime from a number of seconds since the epoch (meaning since 1 January 1970 00:00:00 UTC). Uses the default zone.
|
565 | *
|
566 | * @param seconds - a number of seconds since 1970 UTC
|
567 | * @param options - configuration options for the DateTime
|
568 | * @param options.zone - the zone to place the DateTime into. Defaults to 'local'.
|
569 | * @param options.locale - a locale to set on the resulting DateTime instance
|
570 | * @param options.outputCalendar - the output calendar to set on the resulting DateTime instance
|
571 | * @param options.numberingSystem - the numbering system to set on the resulting DateTime instance
|
572 | */
|
573 | static fromSeconds(seconds: number, options?: DateTimeJSOptions): DateTime;
|
574 |
|
575 | /**
|
576 | * Create a DateTime from a JavaScript object with keys like 'year' and 'hour' with reasonable defaults.
|
577 | *
|
578 | * @param obj - the object to create the DateTime from
|
579 | * @param obj.year - a year, such as 1987
|
580 | * @param obj.month - a month, 1-12
|
581 | * @param obj.day - a day of the month, 1-31, depending on the month
|
582 | * @param obj.ordinal - day of the year, 1-365 or 366
|
583 | * @param obj.weekYear - an ISO week year
|
584 | * @param obj.weekNumber - an ISO week number, between 1 and 52 or 53, depending on the year
|
585 | * @param obj.weekday - an ISO weekday, 1-7, where 1 is Monday and 7 is Sunday
|
586 | * @param obj.hour - hour of the day, 0-23
|
587 | * @param obj.minute - minute of the hour, 0-59
|
588 | * @param obj.second - second of the minute, 0-59
|
589 | * @param obj.millisecond - millisecond of the second, 0-999
|
590 | * @param opts - options for creating this DateTime
|
591 | * @param opts.zone - interpret the numbers in the context of a particular zone. Can take any value taken as the first argument to setZone(). Defaults to 'local'.
|
592 | * @param opts.locale - a locale to set on the resulting DateTime instance. Defaults to 'system's locale'.
|
593 | * @param opts.outputCalendar - the output calendar to set on the resulting DateTime instance
|
594 | * @param opts.numberingSystem - the numbering system to set on the resulting DateTime instance
|
595 | *
|
596 | * @example
|
597 | * DateTime.fromObject({ year: 1982, month: 5, day: 25}).toISODate() //=> '1982-05-25'
|
598 | * @example
|
599 | * DateTime.fromObject({ year: 1982 }).toISODate() //=> '1982-01-01'
|
600 | * @example
|
601 | * DateTime.fromObject({ hour: 10, minute: 26, second: 6 }) //~> today at 10:26:06
|
602 | * @example
|
603 | * DateTime.fromObject({ hour: 10, minute: 26, second: 6 }, { zone: 'utc' }),
|
604 | * @example
|
605 | * DateTime.fromObject({ hour: 10, minute: 26, second: 6 }, { zone: 'local' })
|
606 | * @example
|
607 | * DateTime.fromObject({ hour: 10, minute: 26, second: 6 }, { }zone: 'America/New_York' })
|
608 | * @example
|
609 | * DateTime.fromObject({ weekYear: 2016, weekNumber: 2, weekday: 3 }).toISODate() //=> '2016-01-13'
|
610 | */
|
611 | static fromObject(obj: DateObjectUnits, opts?: DateTimeJSOptions): DateTime;
|
612 |
|
613 | /**
|
614 | * Create a DateTime from an ISO 8601 string
|
615 | *
|
616 | * @param text - the ISO string
|
617 | * @param opts - options to affect the creation
|
618 | * @param opts.zone - use this zone if no offset is specified in the input string itself. Will also convert the time to this zone. Defaults to 'local'.
|
619 | * @param opts.setZone - override the zone with a fixed-offset zone specified in the string itself, if it specifies one. Defaults to false.
|
620 | * @param opts.locale - a locale to set on the resulting DateTime instance. Defaults to 'system's locale'.
|
621 | * @param opts.outputCalendar - the output calendar to set on the resulting DateTime instance
|
622 | * @param opts.numberingSystem - the numbering system to set on the resulting DateTime instance
|
623 | *
|
624 | * @example
|
625 | * DateTime.fromISO('2016-05-25T09:08:34.123')
|
626 | * @example
|
627 | * DateTime.fromISO('2016-05-25T09:08:34.123+06:00')
|
628 | * @example
|
629 | * DateTime.fromISO('2016-05-25T09:08:34.123+06:00', {setZone: true})
|
630 | * @example
|
631 | * DateTime.fromISO('2016-05-25T09:08:34.123', {zone: 'utc'})
|
632 | * @example
|
633 | * DateTime.fromISO('2016-W05-4')
|
634 | */
|
635 | static fromISO(text: string, opts?: DateTimeOptions): DateTime;
|
636 |
|
637 | /**
|
638 | * Create a DateTime from an RFC 2822 string
|
639 | *
|
640 | * @param text - the RFC 2822 string
|
641 | * @param opts - options to affect the creation
|
642 | * @param opts.zone - convert the time to this zone. Since the offset is always specified in the string itself,
|
643 | * this has no effect on the interpretation of string, merely the zone the resulting DateTime is expressed in. Defaults to 'local'
|
644 | * @param opts.setZone - override the zone with a fixed-offset zone specified in the string itself, if it specifies one. Defaults to false.
|
645 | * @param opts.locale - a locale to set on the resulting DateTime instance. Defaults to 'system's locale'.
|
646 | * @param opts.outputCalendar - the output calendar to set on the resulting DateTime instance
|
647 | * @param opts.numberingSystem - the numbering system to set on the resulting DateTime instance
|
648 | *
|
649 | * @example
|
650 | * DateTime.fromRFC2822('25 Nov 2016 13:23:12 GMT')
|
651 | * @example
|
652 | * DateTime.fromRFC2822('Fri, 25 Nov 2016 13:23:12 +0600')
|
653 | * @example
|
654 | * DateTime.fromRFC2822('25 Nov 2016 13:23 Z')
|
655 | */
|
656 | static fromRFC2822(text: string, opts?: DateTimeOptions): DateTime;
|
657 |
|
658 | /**
|
659 | * Create a DateTime from an HTTP header date
|
660 | *
|
661 | * @see https://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3.1
|
662 | *
|
663 | * @param text - the HTTP header date
|
664 | * @param opts - options to affect the creation
|
665 | * @param opts.zone - convert the time to this zone. Since HTTP dates are always in UTC,
|
666 | * this has no effect on the interpretation of string,merely the zone the resulting DateTime is expressed in. Defaults to 'local'.
|
667 | * @param opts.setZone - override the zone with the fixed-offset zone specified in the string. For HTTP dates, this is always UTC,
|
668 | * so this option is equivalent to setting the `zone` option to 'utc', but this option is included for consistency with similar methods. Defaults to false.
|
669 | * @param opts.locale - a locale to set on the resulting DateTime instance. Defaults to 'system's locale'.
|
670 | * @param opts.outputCalendar - the output calendar to set on the resulting DateTime instance
|
671 | * @param opts.numberingSystem - the numbering system to set on the resulting DateTime instance
|
672 | *
|
673 | * @example
|
674 | * DateTime.fromHTTP('Sun, 06 Nov 1994 08:49:37 GMT')
|
675 | * @example
|
676 | * DateTime.fromHTTP('Sunday, 06-Nov-94 08:49:37 GMT')
|
677 | * @example
|
678 | * DateTime.fromHTTP('Sun Nov 6 08:49:37 1994')
|
679 | */
|
680 | static fromHTTP(text: string, opts?: DateTimeOptions): DateTime;
|
681 |
|
682 | /**
|
683 | * Create a DateTime from an input string and format string.
|
684 | * Defaults to en-US if no locale has been specified, regardless of the system's locale. For a table of tokens and their interpretations,
|
685 | * see [here](https://moment.github.io/luxon/#/parsing?id=table-of-tokens).
|
686 | *
|
687 | * @param text - the string to parse
|
688 | * @param fmt - the format the string is expected to be in (see the link below for the formats)
|
689 | * @param opts - options to affect the creation
|
690 | * @param opts.zone - use this zone if no offset is specified in the input string itself. Will also convert the DateTime to this zone. Defaults to 'local'.
|
691 | * @param opts.setZone - override the zone with a zone specified in the string itself, if it specifies one. Defaults to false.
|
692 | * @param opts.locale - a locale string to use when parsing. Will also set the DateTime to this locale. Defaults to 'en-US'.
|
693 | * @param opts.numberingSystem - the numbering system to use when parsing. Will also set the resulting DateTime to this numbering system
|
694 | * @param opts.outputCalendar - the output calendar to set on the resulting DateTime instance
|
695 | */
|
696 | static fromFormat(text: string, fmt: string, opts?: DateTimeOptions): DateTime;
|
697 |
|
698 | /**
|
699 | * @deprecated use fromFormat instead
|
700 | */
|
701 | static fromString(text: string, format: string, options?: DateTimeOptions): DateTime;
|
702 |
|
703 | /**
|
704 | * Create a DateTime from a SQL date, time, or datetime
|
705 | * Defaults to en-US if no locale has been specified, regardless of the system's locale
|
706 | *
|
707 | * @param text - the string to parse
|
708 | * @param opts - options to affect the creation
|
709 | * @param opts.zone - use this zone if no offset is specified in the input string itself. Will also convert the DateTime to this zone. Defaults to 'local'.
|
710 | * @param opts.setZone - override the zone with a zone specified in the string itself, if it specifies one. Defaults to false.
|
711 | * @param opts.locale - a locale string to use when parsing. Will also set the DateTime to this locale. Defaults to 'en-US'.
|
712 | * @param opts.numberingSystem - the numbering system to use when parsing. Will also set the resulting DateTime to this numbering system
|
713 | * @param opts.outputCalendar - the output calendar to set on the resulting DateTime instance
|
714 | *
|
715 | * @example
|
716 | * DateTime.fromSQL('2017-05-15')
|
717 | * @example
|
718 | * DateTime.fromSQL('2017-05-15 09:12:34')
|
719 | * @example
|
720 | * DateTime.fromSQL('2017-05-15 09:12:34.342')
|
721 | * @example
|
722 | * DateTime.fromSQL('2017-05-15 09:12:34.342+06:00')
|
723 | * @example
|
724 | * DateTime.fromSQL('2017-05-15 09:12:34.342 America/Los_Angeles')
|
725 | * @example
|
726 | * DateTime.fromSQL('2017-05-15 09:12:34.342 America/Los_Angeles', { setZone: true })
|
727 | * @example
|
728 | * DateTime.fromSQL('2017-05-15 09:12:34.342', { zone: 'America/Los_Angeles' })
|
729 | * @example
|
730 | * DateTime.fromSQL('09:12:34.342')
|
731 | */
|
732 | static fromSQL(text: string, opts?: DateTimeOptions): DateTime;
|
733 |
|
734 | /**
|
735 | * Create an invalid DateTime.
|
736 | *
|
737 | * @param reason - simple string of why this DateTime is invalid. Should not contain parameters or anything else data-dependent
|
738 | * @param explanation - longer explanation, may include parameters and other useful debugging information. Defaults to null.
|
739 | */
|
740 | static invalid(reason: string, explanation?: string): DateTime;
|
741 |
|
742 | /**
|
743 | * Check if an object is a DateTime. Works across context boundaries
|
744 | *
|
745 | * @param o
|
746 | */
|
747 | static isDateTime(o: unknown): o is DateTime;
|
748 |
|
749 | /**
|
750 | * Produce the format string for a set of options
|
751 | *
|
752 | * @param formatOpts - Intl.DateTimeFormat constructor options and configuration options
|
753 | * @param localeOpts - Opts to override the configuration options on this DateTime
|
754 | *
|
755 | * @example
|
756 | * DateTime.parseFormatForOpts(DateTime.DATETIME_FULL); //=> "MMMM d, yyyyy, h:m a ZZZ"
|
757 | */
|
758 | static parseFormatForOpts(formatOpts?: DateTimeFormatOptions, localeOpts?: LocaleOptions): string | null;
|
759 |
|
760 | /**
|
761 | * Produce the fully expanded format token for the locale
|
762 | * Does NOT quote characters, so quoted tokens will not round trip correctly
|
763 | * @param fmt - the format string
|
764 | * @param localeOpts - Opts to override the configuration options on this DateTime
|
765 | */
|
766 | static expandFormat(fmt: string, localeOpts?: LocaleOptions): string;
|
767 |
|
768 | private constructor(config: unknown);
|
769 |
|
770 | // INFO
|
771 |
|
772 | /**
|
773 | * Get the value of unit.
|
774 | *
|
775 | * @param unit - a unit such as 'minute' or 'day'
|
776 | *
|
777 | * @example
|
778 | * DateTime.local(2017, 7, 4).get('month'); //=> 7
|
779 | * @example
|
780 | * DateTime.local(2017, 7, 4).get('day'); //=> 4
|
781 | */
|
782 | get(unit: keyof DateTime): number;
|
783 |
|
784 | /**
|
785 | * Returns whether the DateTime is valid. Invalid DateTimes occur when:
|
786 | * * The DateTime was created from invalid calendar information, such as the 13th month or February 30
|
787 | * * The DateTime was created by an operation on another invalid date
|
788 | */
|
789 | get isValid(): boolean;
|
790 |
|
791 | /**
|
792 | * Returns an error code if this DateTime is invalid, or null if the DateTime is valid
|
793 | */
|
794 | get invalidReason(): string | null;
|
795 |
|
796 | /**
|
797 | * Returns an explanation of why this DateTime became invalid, or null if the DateTime is valid
|
798 | */
|
799 | get invalidExplanation(): string | null;
|
800 |
|
801 | /**
|
802 | * Get the locale of a DateTime, such 'en-GB'. The locale is used when formatting the DateTime
|
803 | */
|
804 | get locale(): string;
|
805 |
|
806 | /**
|
807 | * Get the numbering system of a DateTime, such 'beng'. The numbering system is used when formatting the DateTime
|
808 | */
|
809 | get numberingSystem(): string;
|
810 |
|
811 | /**
|
812 | * Get the output calendar of a DateTime, such 'islamic'. The output calendar is used when formatting the DateTime
|
813 | */
|
814 | get outputCalendar(): string;
|
815 |
|
816 | /**
|
817 | * Get the time zone associated with this DateTime.
|
818 | */
|
819 | get zone(): Zone;
|
820 |
|
821 | /**
|
822 | * Get the name of the time zone.
|
823 | */
|
824 | get zoneName(): string;
|
825 |
|
826 | /**
|
827 | * Get the year
|
828 | *
|
829 | * @example DateTime.local(2017, 5, 25).year //=> 2017
|
830 | */
|
831 | get year(): number;
|
832 |
|
833 | /**
|
834 | * Get the quarter
|
835 | *
|
836 | * @example DateTime.local(2017, 5, 25).quarter //=> 2
|
837 | */
|
838 | get quarter(): QuarterNumbers;
|
839 |
|
840 | /**
|
841 | * Get the month (1-12).
|
842 | *
|
843 | * @example DateTime.local(2017, 5, 25).month //=> 5
|
844 | */
|
845 | get month(): MonthNumbers;
|
846 |
|
847 | /**
|
848 | * Get the day of the month (1-30ish).
|
849 | *
|
850 | * @example DateTime.local(2017, 5, 25).day //=> 25
|
851 | */
|
852 | get day(): DayNumbers;
|
853 |
|
854 | /**
|
855 | * Get the hour of the day (0-23).
|
856 | *
|
857 | * @example DateTime.local(2017, 5, 25, 9).hour //=> 9
|
858 | */
|
859 | get hour(): HourNumbers;
|
860 |
|
861 | /**
|
862 | * Get the minute of the hour (0-59).
|
863 | *
|
864 | * @example
|
865 | * DateTime.local(2017, 5, 25, 9, 30).minute //=> 30
|
866 | */
|
867 | get minute(): MinuteNumbers;
|
868 |
|
869 | /**
|
870 | * Get the second of the minute (0-59).
|
871 | *
|
872 | * @example
|
873 | * DateTime.local(2017, 5, 25, 9, 30, 52).second //=> 52
|
874 | */
|
875 | get second(): SecondNumbers;
|
876 |
|
877 | /**
|
878 | * Get the millisecond of the second (0-999).
|
879 | *
|
880 | * @example
|
881 | * DateTime.local(2017, 5, 25, 9, 30, 52, 654).millisecond //=> 654
|
882 | */
|
883 | get millisecond(): number;
|
884 |
|
885 | /**
|
886 | * Get the week year
|
887 | * @see https://en.wikipedia.org/wiki/ISO_week_date
|
888 | *
|
889 | * @example
|
890 | * DateTime.local(2014, 12, 31).weekYear //=> 2015
|
891 | */
|
892 | get weekYear(): number;
|
893 |
|
894 | /**
|
895 | * Get the week number of the week year (1-52ish).
|
896 | * @see https://en.wikipedia.org/wiki/ISO_week_date
|
897 | *
|
898 | * @example
|
899 | * DateTime.local(2017, 5, 25).weekNumber //=> 21
|
900 | */
|
901 | get weekNumber(): WeekNumbers;
|
902 |
|
903 | /**
|
904 | * Get the day of the week.
|
905 | * 1 is Monday and 7 is Sunday
|
906 | * @see https://en.wikipedia.org/wiki/ISO_week_date
|
907 | *
|
908 | * @example
|
909 | * DateTime.local(2014, 11, 31).weekday //=> 4
|
910 | */
|
911 | get weekday(): WeekdayNumbers;
|
912 |
|
913 | /**
|
914 | * Get the ordinal (meaning the day of the year)
|
915 | *
|
916 | * @example
|
917 | * DateTime.local(2017, 5, 25).ordinal //=> 145
|
918 | */
|
919 | get ordinal(): number;
|
920 |
|
921 | /**
|
922 | * Get the human readable short month name, such as 'Oct'.
|
923 | * Defaults to the system's locale if no locale has been specified
|
924 | *
|
925 | * @example
|
926 | * DateTime.local(2017, 10, 30).monthShort //=> Oct
|
927 | */
|
928 | get monthShort(): string;
|
929 |
|
930 | /**
|
931 | * Get the human readable long month name, such as 'October'.
|
932 | * Defaults to the system's locale if no locale has been specified
|
933 | *
|
934 | * @example
|
935 | * DateTime.local(2017, 10, 30).monthLong //=> October
|
936 | */
|
937 | get monthLong(): string;
|
938 |
|
939 | /**
|
940 | * Get the human readable short weekday, such as 'Mon'.
|
941 | * Defaults to the system's locale if no locale has been specified
|
942 | *
|
943 | * @example
|
944 | * DateTime.local(2017, 10, 30).weekdayShort //=> Mon
|
945 | */
|
946 | get weekdayShort(): string;
|
947 |
|
948 | /**
|
949 | * Get the human readable long weekday, such as 'Monday'.
|
950 | * Defaults to the system's locale if no locale has been specified
|
951 | *
|
952 | * @example
|
953 | * DateTime.local(2017, 10, 30).weekdayLong //=> Monday
|
954 | */
|
955 | get weekdayLong(): string;
|
956 |
|
957 | /**
|
958 | * Get the UTC offset of this DateTime in minutes
|
959 | *
|
960 | * @example
|
961 | * DateTime.now().offset //=> -240
|
962 | * @example
|
963 | * DateTime.utc().offset //=> 0
|
964 | */
|
965 | get offset(): number;
|
966 |
|
967 | /**
|
968 | * Get the short human name for the zone's current offset, for example "EST" or "EDT".
|
969 | * Defaults to the system's locale if no locale has been specified
|
970 | */
|
971 | get offsetNameShort(): string;
|
972 |
|
973 | /**
|
974 | * Get the long human name for the zone's current offset, for example "Eastern Standard Time" or "Eastern Daylight Time".
|
975 | * Defaults to the system's locale if no locale has been specified
|
976 | */
|
977 | get offsetNameLong(): string;
|
978 |
|
979 | /**
|
980 | * Get whether this zone's offset ever changes, as in a DST.
|
981 | */
|
982 | get isOffsetFixed(): boolean;
|
983 |
|
984 | /**
|
985 | * Get whether the DateTime is in a DST.
|
986 | */
|
987 | get isInDST(): boolean;
|
988 |
|
989 | /**
|
990 | * Returns true if this DateTime is in a leap year, false otherwise
|
991 | *
|
992 | * @example
|
993 | * DateTime.local(2016).isInLeapYear //=> true
|
994 | * @example
|
995 | * DateTime.local(2013).isInLeapYear //=> false
|
996 | */
|
997 | get isInLeapYear(): boolean;
|
998 |
|
999 | /**
|
1000 | * Returns the number of days in this DateTime's month
|
1001 | *
|
1002 | * @example
|
1003 | * DateTime.local(2016, 2).daysInMonth //=> 29
|
1004 | * @example
|
1005 | * DateTime.local(2016, 3).daysInMonth //=> 31
|
1006 | */
|
1007 | get daysInMonth(): PossibleDaysInMonth;
|
1008 |
|
1009 | /**
|
1010 | * Returns the number of days in this DateTime's year
|
1011 | *
|
1012 | * @example
|
1013 | * DateTime.local(2016).daysInYear //=> 366
|
1014 | * @example
|
1015 | * DateTime.local(2013).daysInYear //=> 365
|
1016 | */
|
1017 | get daysInYear(): PossibleDaysInYear;
|
1018 |
|
1019 | /**
|
1020 | * Returns the number of weeks in this DateTime's year
|
1021 | * @see https://en.wikipedia.org/wiki/ISO_week_date
|
1022 | *
|
1023 | * @example
|
1024 | * DateTime.local(2004).weeksInWeekYear //=> 53
|
1025 | * @example
|
1026 | * DateTime.local(2013).weeksInWeekYear //=> 52
|
1027 | */
|
1028 | get weeksInWeekYear(): PossibleWeeksInYear;
|
1029 |
|
1030 | /**
|
1031 | * Returns the resolved Intl options for this DateTime.
|
1032 | * This is useful in understanding the behavior of formatting methods
|
1033 | *
|
1034 | * @param opts - the same options as toLocaleString
|
1035 | */
|
1036 | resolvedLocaleOptions(opts?: LocaleOptions | DateTimeFormatOptions): ResolvedLocaleOptions;
|
1037 |
|
1038 | // TRANSFORM
|
1039 |
|
1040 | /**
|
1041 | * "Set" the DateTime's zone to UTC. Returns a newly-constructed DateTime.
|
1042 | *
|
1043 | * Equivalent to {'utc')
DateTime.setZone}( |
1044 | *
|
1045 | * from UTC in minutes. Defaults to 0.
offset - optionally, an offset |
1046 | * `setZone()`. Defaults to {}.
opts - options to pass to |
1047 | */
|
1048 | toUTC(offset?: number, opts?: ZoneOptions): DateTime;
|
1049 |
|
1050 | /**
|
1051 | * "Set" the DateTime's zone to the host's local zone. Returns a newly-constructed DateTime.
|
1052 | *
|
1053 | * Equivalent to `setZone('local')`
|
1054 | */
|
1055 | toLocal(): DateTime;
|
1056 |
|
1057 | /**
|
1058 | * "Set" the DateTime's zone to specified zone. Returns a newly-constructed DateTime.
|
1059 | *
|
1060 | * By default, the setter keeps the underlying time the same (as in, the same timestamp), but the new instance will report different local times and consider DSTs when making computations,
|
1061 | * as with {@link DateTime.plus}. You may wish to use {@link DateTime.toLocal} and {@link DateTime.toUTC} which provide simple convenience wrappers for commonly used zones.
|
1062 | *
|
1063 | * @param zone - a zone identifier. As a string, that can be any IANA zone supported by the host environment, or a fixed-offset name of the form 'UTC+3', or the strings 'local' or 'utc'.
|
1064 | * You may also supply an instance of a {@link DateTime.Zone} class. Defaults to 'local'.
|
1065 | * @param opts - options
|
1066 | * @param opts.keepLocalTime - If true, adjust the underlying time so that the local time stays the same, but in the target zone. You should rarely need this. Defaults to false.
|
1067 | */
|
1068 | setZone(zone?: string | Zone, opts?: ZoneOptions): DateTime;
|
1069 |
|
1070 | /**
|
1071 | * "Set" the locale, numberingSystem, or outputCalendar. Returns a newly-constructed DateTime.
|
1072 | *
|
1073 | * @param properties - the properties to set
|
1074 | *
|
1075 | * @example
|
1076 | * DateTime.local(2017, 5, 25).reconfigure({ locale: 'en-GB' })
|
1077 | */
|
1078 | reconfigure(properties: LocaleOptions): DateTime;
|
1079 |
|
1080 | /**
|
1081 | * "Set" the locale. Returns a newly-constructed DateTime.
|
1082 | * Just a convenient alias for reconfigure({ locale })
|
1083 | *
|
1084 | * @example
|
1085 | * DateTime.local(2017, 5, 25).setLocale('en-GB')
|
1086 | */
|
1087 | setLocale(locale: string): DateTime;
|
1088 |
|
1089 | /**
|
1090 | * "Set" the values of specified units. Returns a newly-constructed DateTime.
|
1091 | * You can only set units with this method; for "setting" metadata, see {@link DateTime.reconfigure} and {@link DateTime.setZone}.
|
1092 | *
|
1093 | * @param values - a mapping of units to numbers
|
1094 | *
|
1095 | * @example
|
1096 | * dt.set({ year: 2017 })
|
1097 | * @example
|
1098 | * dt.set({ hour: 8, minute: 30 })
|
1099 | * @example
|
1100 | * dt.set({ weekday: 5 })
|
1101 | * @example
|
1102 | * dt.set({ year: 2005, ordinal: 234 })
|
1103 | */
|
1104 | set(values: DateObjectUnits): DateTime;
|
1105 |
|
1106 | /**
|
1107 | * Adding hours, minutes, seconds, or milliseconds increases the timestamp by the right number of milliseconds. Adding days, months, or years shifts the calendar,
|
1108 | * accounting for DSTs and leap years along the way. Thus, `dt.plus({ hours: 24 })` may result in a different time than `dt.plus({ days: 1 })` if there's a DST shift in between.
|
1109 | *
|
1110 | * @param duration - The amount to add. Either a Luxon Duration, a number of milliseconds, the object argument to Duration.fromObject()
|
1111 | *
|
1112 | * @example
|
1113 | * DateTime.now().plus(123) //~> in 123 milliseconds
|
1114 | * @example
|
1115 | * DateTime.now().plus({ minutes: 15 }) //~> in 15 minutes
|
1116 | * @example
|
1117 | * DateTime.now().plus({ days: 1 }) //~> this time tomorrow
|
1118 | * @example
|
1119 | * DateTime.now().plus({ days: -1 }) //~> this time yesterday
|
1120 | * @example
|
1121 | * DateTime.now().plus({ hours: 3, minutes: 13 }) //~> in 3 hr, 13 min
|
1122 | * @example
|
1123 | * DateTime.now().plus(Duration.fromObject({ hours: 3, minutes: 13 })) //~> in 3 hr, 13 min
|
1124 | */
|
1125 | plus(duration: DurationLike): DateTime;
|
1126 |
|
1127 | /**
|
1128 | * See {@link DateTime.plus}
|
1129 | *
|
1130 | * @param duration - The amount to subtract. Either a Luxon Duration, a number of milliseconds, the object argument to Duration.fromObject()
|
1131 | */
|
1132 | minus(duration: DurationLike): DateTime;
|
1133 |
|
1134 | /**
|
1135 | * "Set" this DateTime to the beginning of a unit of time.
|
1136 | *
|
1137 | * @param unit - The unit to go to the beginning of. Can be 'year', 'quarter', 'month', 'week', 'day', 'hour', 'minute', 'second', or 'millisecond'.
|
1138 | *
|
1139 | * @example
|
1140 | * DateTime.local(2014, 3, 3).startOf('month').toISODate(); //=> '2014-03-01'
|
1141 | * @example
|
1142 | * DateTime.local(2014, 3, 3).startOf('year').toISODate(); //=> '2014-01-01'
|
1143 | * @example
|
1144 | * DateTime.local(2014, 3, 3).startOf('week').toISODate(); //=> '2014-03-03', weeks always start on Mondays
|
1145 | * @example
|
1146 | * DateTime.local(2014, 3, 3, 5, 30).startOf('day').toISOTime(); //=> '00:00.000-05:00'
|
1147 | * @example
|
1148 | * DateTime.local(2014, 3, 3, 5, 30).startOf('hour').toISOTime(); //=> '05:00:00.000-05:00'
|
1149 | */
|
1150 | startOf(unit: DateTimeUnit): DateTime;
|
1151 |
|
1152 | /**
|
1153 | * "Set" this DateTime to the end (meaning the last millisecond) of a unit of time
|
1154 | *
|
1155 | * @param unit - The unit to go to the end of. Can be 'year', 'quarter', 'month', 'week', 'day', 'hour', 'minute', 'second', or 'millisecond'.
|
1156 | *
|
1157 | * @example
|
1158 | * DateTime.local(2014, 3, 3).endOf('month').toISO(); //=> '2014-03-31T23:59:59.999-05:00'
|
1159 | * @example
|
1160 | * DateTime.local(2014, 3, 3).endOf('year').toISO(); //=> '2014-12-31T23:59:59.999-05:00'
|
1161 | * @example
|
1162 | * DateTime.local(2014, 3, 3).endOf('week').toISO(); // => '2014-03-09T23:59:59.999-05:00', weeks start on Mondays
|
1163 | * @example
|
1164 | * DateTime.local(2014, 3, 3, 5, 30).endOf('day').toISO(); //=> '2014-03-03T23:59:59.999-05:00'
|
1165 | * @example
|
1166 | * DateTime.local(2014, 3, 3, 5, 30).endOf('hour').toISO(); //=> '2014-03-03T05:59:59.999-05:00'
|
1167 | */
|
1168 | endOf(unit: DateTimeUnit): DateTime;
|
1169 |
|
1170 | // OUTPUT
|
1171 |
|
1172 | /**
|
1173 | * Returns a string representation of this DateTime formatted according to the specified format string.
|
1174 | * **You may not want this.** See {@link DateTime.toLocaleString} for a more flexible formatting tool. For a table of tokens and their interpretations,
|
1175 | * see [here](https://moment.github.io/luxon/#/formatting?id=table-of-tokens).
|
1176 | * Defaults to en-US if no locale has been specified, regardless of the system's locale.
|
1177 | *
|
1178 | * @param fmt - the format string
|
1179 | * @param opts - opts to override the configuration options on this DateTime
|
1180 | *
|
1181 | * @example
|
1182 | * DateTime.now().toFormat('yyyy LLL dd') //=> '2017 Apr 22'
|
1183 | * @example
|
1184 | * DateTime.now().setLocale('fr').toFormat('yyyy LLL dd') //=> '2017 avr. 22'
|
1185 | * @example
|
1186 | * DateTime.now().toFormat('yyyy LLL dd', { locale: "fr" }) //=> '2017 avr. 22'
|
1187 | * @example
|
1188 | * DateTime.now().toFormat("HH 'hours and' mm 'minutes'") //=> '20 hours and 55 minutes'
|
1189 | */
|
1190 | toFormat(fmt: string, opts?: LocaleOptions): string;
|
1191 |
|
1192 | /**
|
1193 | * Returns a localized string representing this date. Accepts the same options as the Intl.DateTimeFormat constructor and any presets defined by Luxon,
|
1194 | * such as `DateTime.DATE_FULL` or `DateTime.TIME_SIMPLE` of the DateTime in the assigned locale.
|
1195 | * Defaults to the system's locale if no locale has been specified
|
1196 | * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat
|
1197 | *
|
1198 | * @param formatOpts - Intl.DateTimeFormat constructor options and configuration options
|
1199 | * @param opts - opts to override the configuration options on this DateTime
|
1200 | *
|
1201 | * @example
|
1202 | * DateTime.now().toLocaleString(); //=> 4/20/2017
|
1203 | * @example
|
1204 | * DateTime.now().setLocale('en-gb').toLocaleString(); //=> '20/04/2017'
|
1205 | * @example
|
1206 | * DateTime.now().toLocaleString({ locale: 'en-gb' }); //=> '20/04/2017'
|
1207 | * @example
|
1208 | * DateTime.now().toLocaleString(DateTime.DATE_FULL); //=> 'April 20, 2017'
|
1209 | * @example
|
1210 | * DateTime.now().toLocaleString(DateTime.TIME_SIMPLE); //=> '11:32 AM'
|
1211 | * @example
|
1212 | * DateTime.now().toLocaleString(DateTime.DATETIME_SHORT); //=> '4/20/2017, 11:32 AM'
|
1213 | * @example
|
1214 | * DateTime.now().toLocaleString({ weekday: 'long', month: 'long', day: '2-digit' }); //=> 'Thursday, April 20'
|
1215 | * @example
|
1216 | * DateTime.now().toLocaleString({ weekday: 'short', month: 'short', day: '2-digit', hour: '2-digit', minute: '2-digit' }); //=> 'Thu, Apr 20, 11:27 AM'
|
1217 | * @example
|
1218 | * DateTime.now().toLocaleString({ hour: '2-digit', minute: '2-digit', hourCycle: 'h23' }); //=> '11:32'
|
1219 | */
|
1220 | toLocaleString(formatOpts?: DateTimeFormatOptions, opts?: LocaleOptions): string;
|
1221 |
|
1222 | /**
|
1223 | * Returns an array of format "parts", meaning individual tokens along with metadata. This is allows callers to post-process individual sections of the formatted output.
|
1224 | * Defaults to the system's locale if no locale has been specified
|
1225 | * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/formatToParts
|
1226 | *
|
1227 | * @param opts - Intl.DateTimeFormat constructor options, same as `toLocaleString`.
|
1228 | *
|
1229 | * @example
|
1230 | * DateTime.now().toLocaleParts(); //=> [
|
1231 | * //=> { type: 'day', value: '25' },
|
1232 | * //=> { type: 'literal', value: '/' },
|
1233 | * //=> { type: 'month', value: '05' },
|
1234 | * //=> { type: 'literal', value: '/' },
|
1235 | * //=> { type: 'year', value: '1982' }
|
1236 | * //=> ]
|
1237 | */
|
1238 | toLocaleParts(opts?: DateTimeFormatOptions): Intl.DateTimeFormatPart[];
|
1239 |
|
1240 | /**
|
1241 | * Returns an ISO 8601-compliant string representation of this DateTime
|
1242 | *
|
1243 | * @param opts - options
|
1244 | * @param opts.suppressMilliseconds - exclude milliseconds from the format if they're 0. Defaults to false.
|
1245 | * @param opts.suppressSeconds - exclude seconds from the format if they're 0. Defaults to false.
|
1246 | * @param opts.includeOffset - include the offset, such as 'Z' or '-04:00'. Defaults to true.
|
1247 | * @param opts.format - choose between the basic and extended format. Defaults to 'extended'.
|
1248 | *
|
1249 | * @example
|
1250 | * DateTime.utc(1982, 5, 25).toISO() //=> '1982-05-25T00:00:00.000Z'
|
1251 | * @example
|
1252 | * DateTime.now().toISO() //=> '2017-04-22T20:47:05.335-04:00'
|
1253 | * @example
|
1254 | * DateTime.now().toISO({ includeOffset: false }) //=> '2017-04-22T20:47:05.335'
|
1255 | * @example
|
1256 | * DateTime.now().toISO({ format: 'basic' }) //=> '20170422T204705.335-0400'
|
1257 | */
|
1258 | toISO(opts?: ToISOTimeOptions): string;
|
1259 |
|
1260 | /**
|
1261 | * Returns an ISO 8601-compliant string representation of this DateTime's date component
|
1262 | *
|
1263 | * @param opts - options
|
1264 | * @param opts.format - choose between the basic and extended format. Defaults to 'extended'.
|
1265 | *
|
1266 | * @example
|
1267 | * DateTime.utc(1982, 5, 25).toISODate() //=> '1982-05-25'
|
1268 | * @example
|
1269 | * DateTime.utc(1982, 5, 25).toISODate({ format: 'basic' }) //=> '19820525'
|
1270 | */
|
1271 | toISODate(opts?: ToISODateOptions): string;
|
1272 |
|
1273 | /**
|
1274 | * Returns an ISO 8601-compliant string representation of this DateTime's week date
|
1275 | *
|
1276 | * @example
|
1277 | * DateTime.utc(1982, 5, 25).toISOWeekDate() //=> '1982-W21-2'
|
1278 | */
|
1279 | toISOWeekDate(): string;
|
1280 |
|
1281 | /**
|
1282 | * Returns an ISO 8601-compliant string representation of this DateTime's time component
|
1283 | *
|
1284 | * @param opts - options
|
1285 | * @param opts.suppressMilliseconds - exclude milliseconds from the format if they're 0. Defaults to false.
|
1286 | * @param opts.suppressSeconds - exclude seconds from the format if they're 0. Defaults to false.
|
1287 | * @param opts.includeOffset - include the offset, such as 'Z' or '-04:00'. Defaults to true.
|
1288 | * @param opts.includePrefix - include the `T` prefix. Defaults to false.
|
1289 | * @param opts.format - choose between the basic and extended format. Defaults to 'extended'.
|
1290 | *
|
1291 | * @example
|
1292 | * DateTime.utc().set({ hour: 7, minute: 34 }).toISOTime() //=> '07:34:19.361Z'
|
1293 | * @example
|
1294 | * DateTime.utc().set({ hour: 7, minute: 34, seconds: 0, milliseconds: 0 }).toISOTime({ suppressSeconds: true }) //=> '07:34Z'
|
1295 | * @example
|
1296 | * DateTime.utc().set({ hour: 7, minute: 34 }).toISOTime({ format: 'basic' }) //=> '073419.361Z'
|
1297 | * @example
|
1298 | * DateTime.utc().set({ hour: 7, minute: 34 }).toISOTime({ includePrefix: true }) //=> 'T07:34:19.361Z'
|
1299 | */
|
1300 | toISOTime(ops?: ToISOTimeOptions): string;
|
1301 |
|
1302 | /**
|
1303 | * Returns an RFC 2822-compatible string representation of this DateTime, always in UTC
|
1304 | *
|
1305 | * @example
|
1306 | * DateTime.utc(2014, 7, 13).toRFC2822() //=> 'Sun, 13 Jul 2014 00:00:00 +0000'
|
1307 | * @example
|
1308 | * DateTime.local(2014, 7, 13).toRFC2822() //=> 'Sun, 13 Jul 2014 00:00:00 -0400'
|
1309 | */
|
1310 | toRFC2822(): string;
|
1311 |
|
1312 | /**
|
1313 | * Returns a string representation of this DateTime appropriate for use in HTTP headers.
|
1314 | * Specifically, the string conforms to RFC 1123.
|
1315 | * @see https://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3.1
|
1316 | *
|
1317 | * @example
|
1318 | * DateTime.utc(2014, 7, 13).toHTTP() //=> 'Sun, 13 Jul 2014 00:00:00 GMT'
|
1319 | * @example
|
1320 | * DateTime.utc(2014, 7, 13, 19).toHTTP() //=> 'Sun, 13 Jul 2014 19:00:00 GMT'
|
1321 | */
|
1322 | toHTTP(): string;
|
1323 |
|
1324 | /**
|
1325 | * Returns a string representation of this DateTime appropriate for use in SQL Date
|
1326 | *
|
1327 | * @example
|
1328 | * DateTime.utc(2014, 7, 13).toSQLDate() //=> '2014-07-13'
|
1329 | */
|
1330 | toSQLDate(): string;
|
1331 |
|
1332 | /**
|
1333 | * Returns a string representation of this DateTime appropriate for use in SQL Time
|
1334 | *
|
1335 | * @param opts - options
|
1336 | * @param opts.includeZone - include the zone, such as 'America/New_York'. Overrides includeOffset. Defaults to false.
|
1337 | * @param opts.includeOffset - include the offset, such as 'Z' or '-04:00'. Defaults to true.
|
1338 | *
|
1339 | * @example
|
1340 | * DateTime.utc().toSQL() //=> '05:15:16.345'
|
1341 | * @example
|
1342 | * DateTime.now().toSQL() //=> '05:15:16.345 -04:00'
|
1343 | * @example
|
1344 | * DateTime.now().toSQL({ includeOffset: false }) //=> '05:15:16.345'
|
1345 | * @example
|
1346 | * DateTime.now().toSQL({ includeZone: false }) //=> '05:15:16.345 America/New_York'
|
1347 | */
|
1348 | toSQLTime(opts?: ToSQLOptions): string;
|
1349 |
|
1350 | /**
|
1351 | * Returns a string representation of this DateTime appropriate for use in SQL DateTime
|
1352 | *
|
1353 | * @param opts - options
|
1354 | * @param opts.includeZone - include the zone, such as 'America/New_York'. Overrides includeOffset. Defaults to false.
|
1355 | * @param opts.includeOffset - include the offset, such as 'Z' or '-04:00'. Defaults to true.
|
1356 | *
|
1357 | * @example
|
1358 | * DateTime.utc(2014, 7, 13).toSQL() //=> '2014-07-13 00:00:00.000 Z'
|
1359 | * @example
|
1360 | * DateTime.local(2014, 7, 13).toSQL() //=> '2014-07-13 00:00:00.000 -04:00'
|
1361 | * @example
|
1362 | * DateTime.local(2014, 7, 13).toSQL({ includeOffset: false }) //=> '2014-07-13 00:00:00.000'
|
1363 | * @example
|
1364 | * DateTime.local(2014, 7, 13).toSQL({ includeZone: true }) //=> '2014-07-13 00:00:00.000 America/New_York'
|
1365 | */
|
1366 | toSQL(opts?: ToSQLOptions): string;
|
1367 |
|
1368 | /**
|
1369 | * Returns a string representation of this DateTime appropriate for debugging
|
1370 | */
|
1371 | toString(): string;
|
1372 |
|
1373 | /**
|
1374 | * Returns the epoch milliseconds of this DateTime. Alias of {@link DateTime.toMillis}
|
1375 | */
|
1376 | valueOf(): number;
|
1377 |
|
1378 | /**
|
1379 | * Returns the epoch milliseconds of this DateTime.
|
1380 | */
|
1381 | toMillis(): number;
|
1382 |
|
1383 | /**
|
1384 | * Returns the epoch seconds of this DateTime.
|
1385 | */
|
1386 | toSeconds(): number;
|
1387 |
|
1388 | /**
|
1389 | * Returns the epoch seconds (as a whole number) of this DateTime.
|
1390 | */
|
1391 | toUnixInteger(): number;
|
1392 |
|
1393 | /**
|
1394 | * Returns an ISO 8601 representation of this DateTime appropriate for use in JSON.
|
1395 | */
|
1396 | toJSON(): string;
|
1397 |
|
1398 | /**
|
1399 | * Returns a BSON serializable equivalent to this DateTime.
|
1400 | */
|
1401 | toBSON(): Date;
|
1402 |
|
1403 | /**
|
1404 | * Returns a JavaScript object with this DateTime's year, month, day, and so on.
|
1405 | *
|
1406 | * @param opts - options for generating the object
|
1407 | * @param opts.includeConfig - include configuration attributes in the output. Defaults to false.
|
1408 | *
|
1409 | * @example
|
1410 | * DateTime.now().toObject() //=> { year: 2017, month: 4, day: 22, hour: 20, minute: 49, second: 42, millisecond: 268 }
|
1411 | */
|
1412 | toObject(opts?: {
|
1413 | /**
|
1414 | * Include configuration attributes in the output
|
1415 | * @defaultValue false
|
1416 | */
|
1417 | includeConfig?: boolean | undefined;
|
1418 | }): ToObjectOutput;
|
1419 |
|
1420 | /**
|
1421 | * Returns a JavaScript Date equivalent to this DateTime.
|
1422 | */
|
1423 | toJSDate(): Date;
|
1424 |
|
1425 | // COMPARE
|
1426 |
|
1427 | /**
|
1428 | * Return the difference between two DateTimes as a Duration.
|
1429 | *
|
1430 | * @param otherDateTime - the DateTime to compare this one to
|
1431 | * @param unit- the unit or array of units (such as 'hours' or 'days') to include in the duration. Defaults to ['milliseconds'].
|
1432 | * @param opts - options that affect the creation of the Duration
|
1433 | * @param opts.conversionAccuracy - the conversion system to use. Defaults to 'casual'.
|
1434 | *
|
1435 | * @example
|
1436 | * var i1 = DateTime.fromISO('1982-05-25T09:45'),
|
1437 | * i2 = DateTime.fromISO('1983-10-14T10:30');
|
1438 | * i2.diff(i1).toObject() //=> { milliseconds: 43807500000 }
|
1439 | * i2.diff(i1, 'hours').toObject() //=> { hours: 12168.75 }
|
1440 | * i2.diff(i1, ['months', 'days']).toObject() //=> { months: 16, days: 19.03125 }
|
1441 | * i2.diff(i1, ['months', 'days', 'hours']).toObject() //=> { months: 16, days: 19, hours: 0.75 }
|
1442 | */
|
1443 | diff(otherDateTime: DateTime, unit?: DurationUnits, opts?: DiffOptions): Duration;
|
1444 |
|
1445 | /**
|
1446 | * Return the difference between this DateTime and right now.
|
1447 | * See {@link DateTime.diff}
|
1448 | *
|
1449 | * @param unit - the unit or units units (such as 'hours' or 'days') to include in the duration. Defaults to ['milliseconds'].
|
1450 | * @param opts - options that affect the creation of the Duration
|
1451 | * @param opts.conversionAccuracy - the conversion system to use. Defaults to 'casual'.
|
1452 | */
|
1453 | diffNow(unit?: DurationUnits, opts?: DiffOptions): Duration;
|
1454 |
|
1455 | /**
|
1456 | * Return an Interval spanning between this DateTime and another DateTime
|
1457 | *
|
1458 | * @param otherDateTime - the other end point of the Interval
|
1459 | */
|
1460 | until(otherDateTime: DateTime): Interval;
|
1461 |
|
1462 | /**
|
1463 | * Return whether this DateTime is in the same unit of time as another DateTime.
|
1464 | * Note that time zones are **ignored** in this comparison, which compares the **local** calendar time. Use {@link DateTime.setZone} to convert one of the dates if needed.
|
1465 | *
|
1466 | * @param otherDateTime - the other DateTime
|
1467 | * @param unit - the unit of time to check sameness on
|
1468 | *
|
1469 | * @example
|
1470 | * DateTime.now().hasSame(otherDT, 'day'); //~> true if otherDT is in the same current calendar day
|
1471 | */
|
1472 | hasSame(otherDateTime: DateTime, unit: DateTimeUnit): boolean;
|
1473 |
|
1474 | /**
|
1475 | * Equality check
|
1476 | * Two DateTimes are equal iff they represent the same millisecond, have the same zone and location, and are both valid.
|
1477 | * To compare just the millisecond values, use `+dt1 === +dt2`.
|
1478 | *
|
1479 | * @param other - the other DateTime
|
1480 | */
|
1481 | equals(other: DateTime): boolean;
|
1482 |
|
1483 | /**
|
1484 | * Returns a string representation of a this time relative to now, such as "in two days". Can only internationalize if your
|
1485 | * platform supports Intl.RelativeTimeFormat. Rounds down by default.
|
1486 | *
|
1487 | * @param options - options that affect the output
|
1488 | * @param options.base - the DateTime to use as the basis to which this time is compared. Defaults to now.
|
1489 | * @param options.style - the style of units, must be "long", "short", or "narrow". Defaults to long.
|
1490 | * @param options.unit - use a specific unit or array of units; if omitted, or an array, the method will pick the best unit.
|
1491 | * Use an array or one of "years", "quarters", "months", "weeks", "days", "hours", "minutes", or "seconds"
|
1492 | * @param options.round - whether to round the numbers in the output. Defaults to true.
|
1493 | * @param options.padding - padding in milliseconds. This allows you to round up the result if it fits inside the threshold. Don't use in combination with {round: false}
|
1494 | * because the decimal output will include the padding. Defaults to 0.
|
1495 | * @param options.locale - override the locale of this DateTime
|
1496 | * @param options.numberingSystem - override the numberingSystem of this DateTime. The Intl system may choose not to honor this
|
1497 | *
|
1498 | * @example
|
1499 | * DateTime.now().plus({ days: 1 }).toRelative() //=> "in 1 day"
|
1500 | * @example
|
1501 | * DateTime.now().setLocale("es").toRelative({ days: 1 }) //=> "dentro de 1 día"
|
1502 | * @example
|
1503 | * DateTime.now().plus({ days: 1 }).toRelative({ locale: "fr" }) //=> "dans 23 heures"
|
1504 | * @example
|
1505 | * DateTime.now().minus({ days: 2 }).toRelative() //=> "2 days ago"
|
1506 | * @example
|
1507 | * DateTime.now().minus({ days: 2 }).toRelative({ unit: "hours" }) //=> "48 hours ago"
|
1508 | * @example
|
1509 | * DateTime.now().minus({ hours: 36 }).toRelative({ round: false }) //=> "1.5 days ago"
|
1510 | */
|
1511 | toRelative(options?: ToRelativeOptions): string | null;
|
1512 |
|
1513 | /**
|
1514 | * Returns a string representation of this date relative to today, such as "yesterday" or "next month".
|
1515 | * Only internationalizes on platforms that supports Intl.RelativeTimeFormat.
|
1516 | *
|
1517 | * @param options - options that affect the output
|
1518 | * @param options.base - the DateTime to use as the basis to which this time is compared. Defaults to now.
|
1519 | * @param options.locale - override the locale of this DateTime
|
1520 | * @param options.unit - use a specific unit; if omitted, the method will pick the unit. Use one of "years", "quarters", "months", "weeks", or "days"
|
1521 | * @param options.numberingSystem - override the numberingSystem of this DateTime. The Intl system may choose not to honor this
|
1522 | *
|
1523 | * @example
|
1524 | * DateTime.now().plus({ days: 1 }).toRelativeCalendar() //=> "tomorrow"
|
1525 | * @example
|
1526 | * DateTime.now().setLocale("es").plus({ days: 1 }).toRelative() //=> ""mañana"
|
1527 | * @example
|
1528 | * DateTime.now().plus({ days: 1 }).toRelativeCalendar({ locale: "fr" }) //=> "demain"
|
1529 | * @example
|
1530 | * DateTime.now().minus({ days: 2 }).toRelativeCalendar() //=> "2 days ago"
|
1531 | */
|
1532 | toRelativeCalendar(options?: ToRelativeCalendarOptions): string | null;
|
1533 |
|
1534 | /**
|
1535 | * Return the min of several date times
|
1536 | *
|
1537 | * @param dateTimes - the DateTimes from which to choose the minimum
|
1538 | */
|
1539 | static min(...dateTimes: DateTime[]): DateTime;
|
1540 |
|
1541 | /**
|
1542 | * Return the max of several date times
|
1543 | *
|
1544 | * @param dateTimes - the DateTimes from which to choose the maximum
|
1545 | */
|
1546 | static max(...dateTimes: DateTime[]): DateTime;
|
1547 |
|
1548 | // MISC
|
1549 |
|
1550 | /**
|
1551 | * Explain how a string would be parsed by fromFormat()
|
1552 | *
|
1553 | * @param text - the string to parse
|
1554 | * @param fmt - the format the string is expected to be in (see description)
|
1555 | * @param options - options taken by fromFormat()
|
1556 | */
|
1557 | static fromFormatExplain(text: string, fmt: string, options?: DateTimeOptions): ExplainedFormat;
|
1558 |
|
1559 | /**
|
1560 | * @deprecated use fromFormatExplain instead
|
1561 | */
|
1562 | static fromStringExplain(text: string, fmt: string, options?: DateTimeOptions): ExplainedFormat;
|
1563 |
|
1564 | // FORMAT PRESETS
|
1565 |
|
1566 | /**
|
1567 | * {@link DateTime.toLocaleString} format like 10/14/1983
|
1568 | */
|
1569 | static get DATE_SHORT(): Intl.DateTimeFormatOptions;
|
1570 |
|
1571 | /**
|
1572 | * {@link DateTime.toLocaleString} format like 'Oct 14, 1983'
|
1573 | */
|
1574 | static get DATE_MED(): Intl.DateTimeFormatOptions;
|
1575 |
|
1576 | /**
|
1577 | * {@link DateTime.toLocaleString} format like 'Fri, Oct 14, 1983'
|
1578 | */
|
1579 | static get DATE_MED_WITH_WEEKDAY(): Intl.DateTimeFormatOptions;
|
1580 |
|
1581 | /**
|
1582 | * {@link DateTime.toLocaleString} format like 'October 14, 1983'
|
1583 | */
|
1584 | static get DATE_FULL(): Intl.DateTimeFormatOptions;
|
1585 |
|
1586 | /**
|
1587 | * {@link DateTime.toLocaleString} format like 'Tuesday, October 14, 1983'
|
1588 | */
|
1589 | static get DATE_HUGE(): Intl.DateTimeFormatOptions;
|
1590 |
|
1591 | /**
|
1592 | * {@link DateTime.toLocaleString} format like '09:30 AM'. Only 12-hour if the locale is.
|
1593 | */
|
1594 | static get TIME_SIMPLE(): Intl.DateTimeFormatOptions;
|
1595 |
|
1596 | /**
|
1597 | * {@link DateTime.toLocaleString} format like '09:30:23 AM'. Only 12-hour if the locale is.
|
1598 | */
|
1599 | static get TIME_WITH_SECONDS(): Intl.DateTimeFormatOptions;
|
1600 |
|
1601 | /**
|
1602 | * {@link DateTime.toLocaleString} format like '09:30:23 AM EDT'. Only 12-hour if the locale is.
|
1603 | */
|
1604 | static get TIME_WITH_SHORT_OFFSET(): Intl.DateTimeFormatOptions;
|
1605 |
|
1606 | /**
|
1607 | * {@link DateTime.toLocaleString} format like '09:30:23 AM Eastern Daylight Time'. Only 12-hour if the locale is.
|
1608 | */
|
1609 | static get TIME_WITH_LONG_OFFSET(): Intl.DateTimeFormatOptions;
|
1610 |
|
1611 | /**
|
1612 | * {@link DateTime.toLocaleString} format like '09:30', always 24-hour.
|
1613 | */
|
1614 | static get TIME_24_SIMPLE(): Intl.DateTimeFormatOptions;
|
1615 |
|
1616 | /**
|
1617 | * {@link DateTime.toLocaleString} format like '09:30:23', always 24-hour.
|
1618 | */
|
1619 | static get TIME_24_WITH_SECONDS(): Intl.DateTimeFormatOptions;
|
1620 |
|
1621 | /**
|
1622 | * {@link DateTime.toLocaleString} format like '09:30:23 EDT', always 24-hour.
|
1623 | */
|
1624 | static get TIME_24_WITH_SHORT_OFFSET(): Intl.DateTimeFormatOptions;
|
1625 |
|
1626 | /**
|
1627 | * {@link DateTime.toLocaleString} format like '09:30:23 Eastern Daylight Time', always 24-hour.
|
1628 | */
|
1629 | static get TIME_24_WITH_LONG_OFFSET(): Intl.DateTimeFormatOptions;
|
1630 |
|
1631 | /**
|
1632 | * {@link DateTime.toLocaleString} format like '10/14/1983, 9:30 AM'. Only 12-hour if the locale is.
|
1633 | */
|
1634 | static get DATETIME_SHORT(): Intl.DateTimeFormatOptions;
|
1635 |
|
1636 | /**
|
1637 | * {@link DateTime.toLocaleString} format like '10/14/1983, 9:30:33 AM'. Only 12-hour if the locale is.
|
1638 | */
|
1639 | static get DATETIME_SHORT_WITH_SECONDS(): Intl.DateTimeFormatOptions;
|
1640 |
|
1641 | /**
|
1642 | * {@link DateTime.toLocaleString} format like 'Oct 14, 1983, 9:30 AM'. Only 12-hour if the locale is.
|
1643 | */
|
1644 | static get DATETIME_MED(): Intl.DateTimeFormatOptions;
|
1645 |
|
1646 | /**
|
1647 | * {@link DateTime.toLocaleString} format like 'Oct 14, 1983, 9:30:33 AM'. Only 12-hour if the locale is.
|
1648 | */
|
1649 | static get DATETIME_MED_WITH_SECONDS(): Intl.DateTimeFormatOptions;
|
1650 |
|
1651 | /**
|
1652 | * {@link DateTime.toLocaleString} format like 'Fri, 14 Oct 1983, 9:30 AM'. Only 12-hour if the locale is.
|
1653 | */
|
1654 | static get DATETIME_MED_WITH_WEEKDAY(): Intl.DateTimeFormatOptions;
|
1655 |
|
1656 | /**
|
1657 | * {@link DateTime.toLocaleString} format like 'October 14, 1983, 9:30 AM EDT'. Only 12-hour if the locale is.
|
1658 | */
|
1659 | static get DATETIME_FULL(): Intl.DateTimeFormatOptions;
|
1660 |
|
1661 | /**
|
1662 | * {@link DateTime.toLocaleString} format like 'October 14, 1983, 9:30:33 AM EDT'. Only 12-hour if the locale is.
|
1663 | */
|
1664 | static get DATETIME_FULL_WITH_SECONDS(): Intl.DateTimeFormatOptions;
|
1665 |
|
1666 | /**
|
1667 | * {@link DateTime.toLocaleString} format like 'Friday, October 14, 1983, 9:30 AM Eastern Daylight Time'. Only 12-hour if the locale is.
|
1668 | */
|
1669 | static get DATETIME_HUGE(): Intl.DateTimeFormatOptions;
|
1670 |
|
1671 | /**
|
1672 | * {@link DateTime.toLocaleString} format like 'Friday, October 14, 1983, 9:30:33 AM Eastern Daylight Time'. Only 12-hour if the locale is.
|
1673 | */
|
1674 | static get DATETIME_HUGE_WITH_SECONDS(): Intl.DateTimeFormatOptions;
|
1675 | }
|