Debian Codegraph @

types-luxon/src/datetime.d.ts

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