declare type CalendarSystem = Intl.DateTimeFormatOptions extends { calendar?: infer T } ? T : | "buddhist" | "chinese" | "coptic" | "ethioaa" | "ethiopic" | "gregory" | "hebrew" | "indian" | "islamic" | "islamicc" | "iso8601" | "japanese" | "persian" | "roc"; declare type CanBeInvalid = TSSettings extends { throwOnInvalid: true } ? false : true; declare type ConversionAccuracy = "casual" | "longterm"; declare type CountOptions = _UseLocaleWeekOption; /** * Represents the ISO 3166-1 alpha-2 country codes of all countries recognized by the library. */ declare type Country = 'AD' | 'AE' | 'AF' | 'AG' | 'AI' | 'AL' | 'AM' | 'AO' | 'AQ' | 'AR' | 'AS' | 'AT' | 'AU' | 'AW' | 'AX' | 'AZ' | 'BA' | 'BB' | 'BD' | 'BE' | 'BF' | 'BG' | 'BH' | 'BI' | 'BJ' | 'BL' | 'BM' | 'BN' | 'BO' | 'BQ' | 'BR' | 'BS' | 'BT' | 'BV' | 'BW' | 'BY' | 'BZ' | 'CA' | 'CC' | 'CD' | 'CF' | 'CG' | 'CH' | 'CI' | 'CK' | 'CL' | 'CM' | 'CN' | 'CO' | 'CR' | 'CU' | 'CV' | 'CW' | 'CX' | 'CY' | 'CZ' | 'DE' | 'DJ' | 'DK' | 'DM' | 'DO' | 'DZ' | 'EC' | 'EE' | 'EG' | 'EH' | 'ER' | 'ES' | 'ET' | 'FI' | 'FJ' | 'FK' | 'FM' | 'FO' | 'FR' | 'GA' | 'GB' | 'GD' | 'GE' | 'GF' | 'GG' | 'GH' | 'GI' | 'GL' | 'GM' | 'GN' | 'GP' | 'GQ' | 'GR' | 'GS' | 'GT' | 'GU' | 'GW' | 'GY' | 'HK' | 'HM' | 'HN' | 'HR' | 'HT' | 'HU' | 'ID' | 'IE' | 'IL' | 'IM' | 'IN' | 'IO' | 'IQ' | 'IR' | 'IS' | 'IT' | 'JE' | 'JM' | 'JO' | 'JP' | 'KE' | 'KG' | 'KH' | 'KI' | 'KM' | 'KN' | 'KP' | 'KR' | 'KW' | 'KY' | 'KZ' | 'LA' | 'LB' | 'LC' | 'LI' | 'LK' | 'LR' | 'LS' | 'LT' | 'LU' | 'LV' | 'LY' | 'MA' | 'MC' | 'MD' | 'ME' | 'MF' | 'MG' | 'MH' | 'MK' | 'ML' | 'MM' | 'MN' | 'MO' | 'MP' | 'MQ' | 'MR' | 'MS' | 'MT' | 'MU' | 'MV' | 'MW' | 'MX' | 'MY' | 'MZ' | 'NA' | 'NC' | 'NE' | 'NF' | 'NG' | 'NI' | 'NL' | 'NO' | 'NP' | 'NR' | 'NU' | 'NZ' | 'OM' | 'PA' | 'PE' | 'PF' | 'PG' | 'PH' | 'PK' | 'PL' | 'PM' | 'PN' | 'PR' | 'PS' | 'PT' | 'PW' | 'PY' | 'QA' | 'RE' | 'RO' | 'RS' | 'RU' | 'RW' | 'SA' | 'SB' | 'SC' | 'SD' | 'SE' | 'SG' | 'SH' | 'SI' | 'SJ' | 'SK' | 'SL' | 'SM' | 'SN' | 'SO' | 'SR' | 'SS' | 'ST' | 'SV' | 'SX' | 'SY' | 'SZ' | 'TC' | 'TD' | 'TF' | 'TG' | 'TH' | 'TJ' | 'TK' | 'TL' | 'TM' | 'TN' | 'TO' | 'TR' | 'TT' | 'TV' | 'TW' | 'TZ' | 'UA' | 'UG' | 'UM' | 'US' | 'UY' | 'UZ' | 'VA' | 'VC' | 'VE' | 'VG' | 'VI' | 'VN' | 'VU' | 'WF' | 'WS' | 'XK' | 'YE' | 'YT' | 'ZA' | 'ZM' | 'ZW'; /** * Represents either the ISO 3166-1 alpha-2 country codes of all countries recognized by the library or the string `'XX'` to represent an unknown country. */ declare type CountryOrUnknown = Country | 'XX'; /** * Represents the possible timezones of all countries recognized by the library. */ declare type CountryTimezone = 'Europe/Andorra' | 'Asia/Dubai' | 'Asia/Kabul' | 'America/Antigua' | 'America/Anguilla' | 'Europe/Tirane' | 'Asia/Yerevan' | 'Africa/Luanda' | 'Antarctica/Casey' | 'America/Argentina/Buenos_Aires' | 'Pacific/Pago_Pago' | 'Europe/Vienna' | 'Australia/Sydney' | 'America/Aruba' | 'Europe/Mariehamn' | 'Asia/Baku' | 'Europe/Sarajevo' | 'America/Barbados' | 'Asia/Dhaka' | 'Europe/Brussels' | 'Africa/Ouagadougou' | 'Europe/Sofia' | 'Asia/Bahrain' | 'Africa/Bujumbura' | 'Africa/Porto-Novo' | 'America/St_Barthelemy' | 'Atlantic/Bermuda' | 'Asia/Brunei' | 'America/La_Paz' | 'America/Kralendijk' | 'America/Sao_Paulo' | 'America/Nassau' | 'Asia/Thimphu' | 'Africa/Gaborone' | 'Europe/Minsk' | 'America/Belize' | 'America/Toronto' | 'Indian/Cocos' | 'Africa/Kinshasa' | 'Africa/Bangui' | 'Africa/Brazzaville' | 'Europe/Zurich' | 'Africa/Abidjan' | 'Pacific/Rarotonga' | 'America/Santiago' | 'Africa/Douala' | 'Asia/Shanghai' | 'America/Bogota' | 'America/Costa_Rica' | 'America/Havana' | 'Atlantic/Cape_Verde' | 'America/Curacao' | 'Indian/Christmas' | 'Asia/Nicosia' | 'Europe/Prague' | 'Europe/Berlin' | 'Africa/Djibouti' | 'Europe/Copenhagen' | 'America/Dominica' | 'America/Santo_Domingo' | 'Africa/Algiers' | 'America/Guayaquil' | 'Europe/Tallinn' | 'Africa/Cairo' | 'Africa/El_Aaiun' | 'Africa/Asmara' | 'Europe/Madrid' | 'Africa/Addis_Ababa' | 'Europe/Helsinki' | 'Pacific/Fiji' | 'Atlantic/Stanley' | 'Pacific/Pohnpei' | 'Atlantic/Faroe' | 'Europe/Paris' | 'Africa/Libreville' | 'Europe/London' | 'America/Grenada' | 'Asia/Tbilisi' | 'America/Cayenne' | 'Europe/Guernsey' | 'Africa/Accra' | 'Europe/Gibraltar' | 'America/Godthab' | 'Africa/Banjul' | 'Africa/Conakry' | 'America/Guadeloupe' | 'Africa/Malabo' | 'Europe/Athens' | 'Atlantic/South_Georgia' | 'America/Guatemala' | 'Pacific/Guam' | 'Africa/Bissau' | 'America/Guyana' | 'Asia/Hong_Kong' | 'America/Tegucigalpa' | 'Europe/Zagreb' | 'America/Port-au-Prince' | 'Europe/Budapest' | 'Asia/Jakarta' | 'Europe/Dublin' | 'Asia/Jerusalem' | 'Europe/Isle_of_Man' | 'Asia/Kolkata' | 'Indian/Chagos' | 'Asia/Baghdad' | 'Asia/Tehran' | 'Atlantic/Reykjavik' | 'Europe/Rome' | 'Europe/Jersey' | 'America/Jamaica' | 'Asia/Amman' | 'Asia/Tokyo' | 'Africa/Nairobi' | 'Asia/Bishkek' | 'Asia/Phnom_Penh' | 'Pacific/Tarawa' | 'Indian/Comoro' | 'America/St_Kitts' | 'Asia/Pyongyang' | 'Asia/Seoul' | 'Asia/Kuwait' | 'America/Cayman' | 'Asia/Almaty' | 'Asia/Vientiane' | 'Asia/Beirut' | 'America/St_Lucia' | 'Europe/Vaduz' | 'Asia/Colombo' | 'Africa/Monrovia' | 'Africa/Maseru' | 'Europe/Vilnius' | 'Europe/Luxembourg' | 'Europe/Riga' | 'Africa/Tripoli' | 'Africa/Casablanca' | 'Europe/Monaco' | 'Europe/Chisinau' | 'Europe/Podgorica' | 'America/Marigot' | 'Indian/Antananarivo' | 'Pacific/Majuro' | 'Europe/Skopje' | 'Africa/Bamako' | 'Asia/Yangon' | 'Asia/Ulaanbaatar' | 'Asia/Macau' | 'Pacific/Saipan' | 'America/Martinique' | 'Africa/Nouakchott' | 'America/Montserrat' | 'Europe/Malta' | 'Indian/Mauritius' | 'Indian/Maldives' | 'Africa/Blantyre' | 'America/Mexico_City' | 'Asia/Kuala_Lumpur' | 'Africa/Maputo' | 'Africa/Windhoek' | 'Pacific/Noumea' | 'Africa/Niamey' | 'Pacific/Norfolk' | 'Africa/Lagos' | 'America/Managua' | 'Europe/Amsterdam' | 'Europe/Oslo' | 'Asia/Kathmandu' | 'Pacific/Nauru' | 'Pacific/Niue' | 'Pacific/Auckland' | 'Asia/Muscat' | 'America/Panama' | 'America/Lima' | 'Pacific/Tahiti' | 'Pacific/Port_Moresby' | 'Asia/Manila' | 'Asia/Karachi' | 'Europe/Warsaw' | 'America/Miquelon' | 'Pacific/Pitcairn' | 'America/Puerto_Rico' | 'Asia/Gaza' | 'Europe/Lisbon' | 'Pacific/Palau' | 'America/Asuncion' | 'Asia/Qatar' | 'Indian/Reunion' | 'Europe/Bucharest' | 'Europe/Belgrade' | 'Europe/Moscow' | 'Africa/Kigali' | 'Asia/Riyadh' | 'Pacific/Guadalcanal' | 'Indian/Mahe' | 'Africa/Khartoum' | 'Europe/Stockholm' | 'Asia/Singapore' | 'Atlantic/St_Helena' | 'Europe/Ljubljana' | 'Arctic/Longyearbyen' | 'Europe/Bratislava' | 'Africa/Freetown' | 'Europe/San_Marino' | 'Africa/Dakar' | 'Africa/Mogadishu' | 'America/Paramaribo' | 'Africa/Juba' | 'Africa/Sao_Tome' | 'America/El_Salvador' | 'America/Lower_Princes' | 'Asia/Damascus' | 'Africa/Mbabane' | 'America/Grand_Turk' | 'Africa/Ndjamena' | 'Indian/Kerguelen' | 'Africa/Lome' | 'Asia/Bangkok' | 'Asia/Dushanbe' | 'Pacific/Fakaofo' | 'Asia/Dili' | 'Asia/Ashgabat' | 'Africa/Tunis' | 'Pacific/Tongatapu' | 'Europe/Istanbul' | 'America/Port_of_Spain' | 'Pacific/Funafuti' | 'Asia/Taipei' | 'Africa/Dar_es_Salaam' | 'Europe/Kiev' | 'Africa/Kampala' | 'Pacific/Wake' | 'America/New_York' | 'America/Montevideo' | 'Asia/Tashkent' | 'Europe/Vatican' | 'America/St_Vincent' | 'America/Caracas' | 'America/Tortola' | 'America/St_Thomas' | 'Asia/Ho_Chi_Minh' | 'Pacific/Efate' | 'Pacific/Wallis' | 'Pacific/Apia' | 'Asia/Aden' | 'Indian/Mayotte' | 'Africa/Johannesburg' | 'Africa/Lusaka' | 'Africa/Harare'; declare type DateInput = DateTime | DateObjectUnits | Date; /** * Note that ISO weekday and local weekday fields are mutually exclusive */ declare interface DateObjectUnits { // a year, such as 1987 year?: number | undefined; // a month, 1-12 month?: number | undefined; // a day of the month, 1-31, depending on the month day?: number | undefined; // day of the year, 1-365 or 366 ordinal?: number | undefined; // an ISO week year weekYear?: number | undefined; // a week year, according to the locale localWeekYear?: number | undefined; // an ISO week number, between 1 and 52 or 53, depending on the year weekNumber?: number | undefined; // a week number, between 1 and 52 or 53, depending on the year, according to the locale localWeekNumber?: number | undefined; // an ISO weekday, 1-7, where 1 is Monday and 7 is Sunday weekday?: WeekdayNumbers | undefined; // a weekday, 1-7, where 1 is the first day of the week, and 7 is the last, according to the locale localWeekday?: WeekdayNumbers | undefined; // hour of the day, 0-23 hour?: number | undefined; // minute of the hour, 0-59 minute?: number | undefined; // second of the minute, 0-59 second?: number | undefined; // millisecond of the second, 0-999 millisecond?: number | undefined; } /** * A DateTime is an immutable data structure representing a specific date and time and accompanying methods. * It contains class and instance methods for creating, parsing, interrogating, transforming, and formatting them. * * A DateTime consists of the following parts: * * A timestamp. Each DateTime instance refers to a specific millisecond of the Unix epoch. * * A time zone. Each instance is considered in the context of a specific zone (by default, the local system's zone). * * Configuration properties that affect how output strings are formatted, such as `locale`, `numberingSystem`, and `outputCalendar`. * * Here is a brief overview of the most commonly used functionality it provides: * * * **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}. * To create one from a standard string format, use {@link DateTime.fromISO}, {@link DateTime.fromHTTP}, and {@link DateTime.fromRFC2822}. * To create one from a custom string format, use {@link DateTime.fromFormat}. To create one from a native JS date, use {@link DateTime.fromJSDate}. * * **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}, * {@link DateTime#month}, {@link DateTime#day}, {@link DateTime#hour}, {@link DateTime#minute}, {@link DateTime#second}, {@link DateTime#millisecond} accessors. * * **Week calendar**: For ISO week calendar attributes, see the {@link DateTime#weekYear}, {@link DateTime#weekNumber}, and {@link DateTime#weekday} accessors. * * **Configuration** See the {@link DateTime#locale} and {@link DateTime#numberingSystem} accessors. * * **Transformation**: To transform the DateTime into other DateTimes, use {@link DateTime#set}, {@link DateTime#reconfigure}, {@link DateTime#setZone}, {@link DateTime#setLocale}, * {@link DateTime.plus}, {@link DateTime#minus}, {@link DateTime#endOf}, {@link DateTime#startOf}, {@link DateTime#toUTC}, and {@link DateTime#toLocal}. * * **Output**: To convert the DateTime to other representations, use the {@link DateTime#toRelative}, {@link DateTime#toRelativeCalendar}, {@link DateTime#toJSON}, {@link DateTime#toISO}, * {@link DateTime#toHTTP}, {@link DateTime#toObject}, {@link DateTime#toRFC2822}, {@link DateTime#toString}, {@link DateTime#toLocaleString}, {@link DateTime#toFormat}, * {@link DateTime#toMillis} and {@link DateTime#toJSDate}. * * There's plenty others documented below. In addition, for more information on subtler topics * like internationalization, time zones, alternative calendars, validity, and so on, see the external documentation. */ declare class DateTime { /** * Create a DateTime for the current instant, in the system's time zone. * * Use Settings to override these default values if needed. * @example * DateTime.now().toISO() //~> now in the ISO format */ static now(): DateTime; /** * Create a local DateTime * * @param year - The calendar year. If omitted (as in, call `local()` with no arguments), the current time will be used * @param month - The month, 1-indexed * @param day - The day of the month, 1-indexed * @param hour - The hour of the day, in 24-hour time * @param minute - The minute of the hour, meaning a number between 0 and 59 * @param second - The second of the minute, meaning a number between 0 and 59 * @param millisecond - The millisecond of the second, meaning a number between 0 and 999 * @param opts * * @example * DateTime.local() //~> now * @example * DateTime.local({ zone: "America/New_York" }) //~> now, in US east coast time * @example * DateTime.local(2017) //~> 2017-01-01T00:00:00 * @example * DateTime.local(2017, 3) //~> 2017-03-01T00:00:00 * @example * DateTime.local(2017, 3, 12, { locale: "fr") //~> 2017-03-12T00:00:00, with a French locale * @example * DateTime.local(2017, 3, 12, 5) //~> 2017-03-12T05:00:00 * @example * DateTime.local(2017, 3, 12, 5, { zone: "utc" }) //~> 2017-03-12T05:00:00, in UTC * @example * DateTime.local(2017, 3, 12, 5, 45) //~> 2017-03-12T05:45:00 * @example * DateTime.local(2017, 3, 12, 5, 45, 10) //~> 2017-03-12T05:45:10 * @example * DateTime.local(2017, 3, 12, 5, 45, 10, 765) //~> 2017-03-12T05:45:10.765 */ static local( year: number, month: number, day: number, hour: number, minute: number, second: number, millisecond: number, opts?: DateTimeJSOptions, ): DateTimeMaybeValid; static local( year: number, month: number, day: number, hour: number, minute: number, second: number, opts?: DateTimeJSOptions, ): DateTimeMaybeValid; static local( year: number, month: number, day: number, hour: number, minute: number, opts?: DateTimeJSOptions, ): DateTimeMaybeValid; static local(year: number, month: number, day: number, hour: number, opts?: DateTimeJSOptions): DateTimeMaybeValid; static local(year: number, month: number, day: number, opts?: DateTimeJSOptions): DateTimeMaybeValid; static local(year: number, month: number, opts?: DateTimeJSOptions): DateTimeMaybeValid; static local(year: number, opts?: DateTimeJSOptions): DateTimeMaybeValid; static local(opts?: DateTimeJSOptions): DateTime; /** * Create a DateTime in UTC * * @param year - The calendar year. If omitted (as in, call `utc()` with no arguments), the current time will be used * @param month - The month, 1-indexed * @param day - The day of the month * @param hour - The hour of the day, in 24-hour time * @param minute - The minute of the hour, meaning a number between 0 and 59 * @param second - The second of the minute, meaning a number between 0 and 59 * @param millisecond - The millisecond of the second, meaning a number between 0 and 999 * @param options - configuration options for the DateTime * @param options.locale - a locale to set on the resulting DateTime instance * @param options.outputCalendar - the output calendar to set on the resulting DateTime instance * @param options.numberingSystem - the numbering system to set on the resulting DateTime instance * * @example * DateTime.utc() //~> now * @example * DateTime.utc(2017) //~> 2017-01-01T00:00:00Z * @example * DateTime.utc(2017, 3) //~> 2017-03-01T00:00:00Z * @example * DateTime.utc(2017, 3, 12) //~> 2017-03-12T00:00:00Z * @example * DateTime.utc(2017, 3, 12, 5) //~> 2017-03-12T05:00:00Z * @example * DateTime.utc(2017, 3, 12, 5, 45) //~> 2017-03-12T05:45:00Z * @example * DateTime.utc(2017, 3, 12, 5, 45, { locale: "fr" } ) //~> 2017-03-12T05:45:00Z with a French locale * @example * DateTime.utc(2017, 3, 12, 5, 45, 10) //~> 2017-03-12T05:45:10Z * @example * DateTime.utc(2017, 3, 12, 5, 45, 10, 765, { locale: "fr") //~> 2017-03-12T05:45:10.765Z with a French locale */ static utc( year: number, month: number, day: number, hour: number, minute: number, second: number, millisecond: number, options?: LocaleOptions, ): DateTimeMaybeValid; static utc( year: number, month: number, day: number, hour: number, minute: number, second: number, options?: LocaleOptions, ): DateTimeMaybeValid; static utc( year: number, month: number, day: number, hour: number, minute: number, options?: LocaleOptions, ): DateTimeMaybeValid; static utc(year: number, month: number, day: number, hour: number, options?: LocaleOptions): DateTimeMaybeValid; static utc(year: number, month: number, day: number, options?: LocaleOptions): DateTimeMaybeValid; static utc(year: number, month: number, options?: LocaleOptions): DateTimeMaybeValid; static utc(year: number, options?: LocaleOptions): DateTimeMaybeValid; static utc(options?: LocaleOptions): DateTime; /** * Create a DateTime from a JavaScript Date object. Uses the default zone. * * @param date - a JavaScript Date object * @param options - configuration options for the DateTime * @param options.zone - the zone to place the DateTime into */ static fromJSDate(date: Date, options?: { zone?: string | Zone }): DateTimeMaybeValid; /** * Create a DateTime from a number of milliseconds since the epoch (meaning since 1 January 1970 00:00:00 UTC). Uses the default zone. * * @param milliseconds - a number of milliseconds since 1970 UTC * @param options - configuration options for the DateTime * @param options.zone - the zone to place the DateTime into. Defaults to 'local'. * @param options.locale - a locale to set on the resulting DateTime instance * @param options.outputCalendar - the output calendar to set on the resulting DateTime instance * @param options.numberingSystem - the numbering system to set on the resulting DateTime instance */ static fromMillis(milliseconds: number, options?: DateTimeJSOptions): DateTimeMaybeValid; /** * Create a DateTime from a number of seconds since the epoch (meaning since 1 January 1970 00:00:00 UTC). Uses the default zone. * * @param seconds - a number of seconds since 1970 UTC * @param options - configuration options for the DateTime * @param options.zone - the zone to place the DateTime into. Defaults to 'local'. * @param options.locale - a locale to set on the resulting DateTime instance * @param options.outputCalendar - the output calendar to set on the resulting DateTime instance * @param options.numberingSystem - the numbering system to set on the resulting DateTime instance */ static fromSeconds(seconds: number, options?: DateTimeJSOptions): DateTimeMaybeValid; /** * Create a DateTime from a JavaScript object with keys like 'year' and 'hour' with reasonable defaults. * * @param obj - the object to create the DateTime from * @param obj.year - a year, such as 1987 * @param obj.month - a month, 1-12 * @param obj.day - a day of the month, 1-31, depending on the month * @param obj.ordinal - day of the year, 1-365 or 366 * @param obj.weekYear - an ISO week year * @param obj.weekNumber - an ISO week number, between 1 and 52 or 53, depending on the year * @param obj.weekday - an ISO weekday, 1-7, where 1 is Monday and 7 is Sunday * @param obj.hour - hour of the day, 0-23 * @param obj.minute - minute of the hour, 0-59 * @param obj.second - second of the minute, 0-59 * @param obj.millisecond - millisecond of the second, 0-999 * @param opts - options for creating this DateTime * @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'. * @param opts.locale - a locale to set on the resulting DateTime instance. Defaults to 'system's locale'. * @param opts.outputCalendar - the output calendar to set on the resulting DateTime instance * @param opts.numberingSystem - the numbering system to set on the resulting DateTime instance * * @example * DateTime.fromObject({ year: 1982, month: 5, day: 25}).toISODate() //=> '1982-05-25' * @example * DateTime.fromObject({ year: 1982 }).toISODate() //=> '1982-01-01' * @example * DateTime.fromObject({ hour: 10, minute: 26, second: 6 }) //=> today at 10:26:06 * @example * DateTime.fromObject({ hour: 10, minute: 26, second: 6 }, { zone: 'utc' }) * @example * DateTime.fromObject({ hour: 10, minute: 26, second: 6 }, { zone: 'local' }) * @example * DateTime.fromObject({ hour: 10, minute: 26, second: 6 }, { zone: 'America/New_York' }) * @example * DateTime.fromObject({ weekYear: 2016, weekNumber: 2, weekday: 3 }).toISODate() //=> '2016-01-13' * @example * DateTime.fromObject({ localWeekYear: 2022, localWeekNumber: 1, localWeekday: 1 }, { locale: 'en-US' }).toISODate() //=> '2021-12-26' */ static fromObject(obj: DateObjectUnits, opts?: DateTimeJSOptions): DateTimeMaybeValid; /** * Create a DateTime from an ISO 8601 string * * @param text - the ISO string * @param opts - options to affect the creation * @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'. * @param opts.setZone - override the zone with a fixed-offset zone specified in the string itself, if it specifies one. Defaults to false. * @param opts.locale - a locale to set on the resulting DateTime instance. Defaults to 'system's locale'. * @param opts.outputCalendar - the output calendar to set on the resulting DateTime instance * @param opts.numberingSystem - the numbering system to set on the resulting DateTime instance * * @example * DateTime.fromISO('2016-05-25T09:08:34.123') * @example * DateTime.fromISO('2016-05-25T09:08:34.123+06:00') * @example * DateTime.fromISO('2016-05-25T09:08:34.123+06:00', {setZone: true}) * @example * DateTime.fromISO('2016-05-25T09:08:34.123', {zone: 'utc'}) * @example * DateTime.fromISO('2016-W05-4') */ static fromISO(text: string, opts?: DateTimeOptions): DateTimeMaybeValid; /** * Create a DateTime from an RFC 2822 string * * @param text - the RFC 2822 string * @param opts - options to affect the creation * @param opts.zone - convert the time to this zone. Since the offset is always specified in the string itself, * this has no effect on the interpretation of string, merely the zone the resulting DateTime is expressed in. Defaults to 'local' * @param opts.setZone - override the zone with a fixed-offset zone specified in the string itself, if it specifies one. Defaults to false. * @param opts.locale - a locale to set on the resulting DateTime instance. Defaults to 'system's locale'. * @param opts.outputCalendar - the output calendar to set on the resulting DateTime instance * @param opts.numberingSystem - the numbering system to set on the resulting DateTime instance * * @example * DateTime.fromRFC2822('25 Nov 2016 13:23:12 GMT') * @example * DateTime.fromRFC2822('Fri, 25 Nov 2016 13:23:12 +0600') * @example * DateTime.fromRFC2822('25 Nov 2016 13:23 Z') */ static fromRFC2822(text: string, opts?: DateTimeOptions): DateTimeMaybeValid; /** * Create a DateTime from an HTTP header date * * @see https://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3.1 * * @param text - the HTTP header date * @param opts - options to affect the creation * @param opts.zone - convert the time to this zone. Since HTTP dates are always in UTC, * this has no effect on the interpretation of string,merely the zone the resulting DateTime is expressed in. Defaults to 'local'. * @param opts.setZone - override the zone with the fixed-offset zone specified in the string. For HTTP dates, this is always UTC, * 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. * @param opts.locale - a locale to set on the resulting DateTime instance. Defaults to 'system's locale'. * @param opts.outputCalendar - the output calendar to set on the resulting DateTime instance * @param opts.numberingSystem - the numbering system to set on the resulting DateTime instance * * @example * DateTime.fromHTTP('Sun, 06 Nov 1994 08:49:37 GMT') * @example * DateTime.fromHTTP('Sunday, 06-Nov-94 08:49:37 GMT') * @example * DateTime.fromHTTP('Sun Nov 6 08:49:37 1994') */ static fromHTTP(text: string, opts?: DateTimeOptions): DateTimeMaybeValid; /** * Create a DateTime from an input string and format string. * * Defaults to en-US if no locale has been specified, regardless of the system's locale. * * For a table of tokens and their interpretations, * see [here](https://moment.github.io/luxon/#/parsing?id=table-of-tokens). * * @param text - the string to parse * @param format - the format the string is expected to be in (see the link below for the formats) * @param opts - options to affect the creation * @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'. * @param opts.setZone - override the zone with a zone specified in the string itself, if it specifies one. * Defaults to false. * @param opts.locale - a locale string to use when parsing. * Will also set the DateTime to this locale. * Defaults to 'en-US'. * @param opts.numberingSystem - the numbering system to use when parsing. * Will also set the resulting DateTime to this numbering system * @param opts.outputCalendar - the output calendar to set on the resulting DateTime instance */ static fromFormat(text: string, format: Tokens, opts?: DateTimeOptions): DateTimeMaybeValid; /** * @deprecated use fromFormat instead */ static fromString(text: string, format: Tokens, options?: DateTimeOptions): DateTimeMaybeValid; /** * Create a DateTime from a SQL date, time, or datetime * Defaults to en-US if no locale has been specified, regardless of the system's locale * * @param text - the string to parse * @param opts - options to affect the creation * @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'. * @param opts.setZone - override the zone with a zone specified in the string itself, if it specifies one. Defaults to false. * @param opts.locale - a locale string to use when parsing. Will also set the DateTime to this locale. Defaults to 'en-US'. * @param opts.numberingSystem - the numbering system to use when parsing. Will also set the resulting DateTime to this numbering system * @param opts.outputCalendar - the output calendar to set on the resulting DateTime instance * * @example * DateTime.fromSQL('2017-05-15') * @example * DateTime.fromSQL('2017-05-15 09:12:34') * @example * DateTime.fromSQL('2017-05-15 09:12:34.342') * @example * DateTime.fromSQL('2017-05-15 09:12:34.342+06:00') * @example * DateTime.fromSQL('2017-05-15 09:12:34.342 America/Los_Angeles') * @example * DateTime.fromSQL('2017-05-15 09:12:34.342 America/Los_Angeles', { setZone: true }) * @example * DateTime.fromSQL('2017-05-15 09:12:34.342', { zone: 'America/Los_Angeles' }) * @example * DateTime.fromSQL('09:12:34.342') */ static fromSQL(text: string, opts?: DateTimeOptions): DateTimeMaybeValid; /** * Create an invalid DateTime. * * @param reason - simple string of why this DateTime is invalid. Should not contain parameters or anything else data-dependent * @param explanation - longer explanation, may include parameters and other useful debugging information. Defaults to null. */ static invalid(reason: string, explanation?: string): DateTime; /** * Check if an object is a DateTime. Works across context boundaries * * @param o */ static isDateTime(o: unknown): o is DateTimeMaybeValid; /** * Produce the format string for a set of options * * @param formatOpts - Intl.DateTimeFormat constructor options and configuration options * @param localeOpts - Opts to override the configuration options on this DateTime * * @example * DateTime.parseFormatForOpts(DateTime.DATETIME_FULL); //=> "MMMM d, yyyyy, h:m a ZZZ" */ static parseFormatForOpts(formatOpts?: DateTimeFormatOptions, localeOpts?: LocaleOptions): string | null; /** * Produce the fully expanded format token for the locale * * Does NOT quote characters, so quoted tokens will not round trip correctly * * @param format - the format string - see {@link Tokens} * @param localeOptions - Options to override the configuration options on this DateTime */ static expandFormat(format: Tokens, localeOptions?: LocaleOptions): string; private constructor(config: unknown); // INFO /** * Get the value of unit. * * @param unit - a unit such as 'minute' or 'day' * * @example * DateTime.local(2017, 7, 4).get('month'); //=> 7 * @example * DateTime.local(2017, 7, 4).get('day'); //=> 4 */ get(unit: keyof DateTime): number; /** * Get those DateTimes which have the same local time as this DateTime, but a different offset from UTC in this DateTime's zone. * 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. * This method will return both possible DateTimes if this DateTime's local time is ambiguous. */ getPossibleOffsets(): this[]; /** * Returns whether the DateTime is valid. Invalid DateTimes occur when: * * The DateTime was created from invalid calendar information, such as the 13th month or February 30 * * The DateTime was created by an operation on another invalid date */ get isValid(): IfValid; /** * Returns an error code if this DateTime is invalid, or null if the DateTime is valid */ get invalidReason(): IfValid; /** * Returns an explanation of why this DateTime became invalid, or null if the DateTime is valid */ get invalidExplanation(): IfValid; /** * Get the locale of a DateTime, such as 'en-GB'. The locale is used when formatting the DateTime */ get locale(): IfValid; /** * Get the numbering system of a DateTime, such as 'beng'. The numbering system is used when formatting the DateTime */ get numberingSystem(): IfValid; /** * Get the output calendar of a DateTime, such as 'islamic'. The output calendar is used when formatting the DateTime */ get outputCalendar(): IfValid; /** * Get the time zone associated with this DateTime. */ get zone(): Zone; /** * Get the name of the time zone. */ get zoneName(): IfValid; /** * Get the year * * @example DateTime.local(2017, 5, 25).year //=> 2017 */ get year(): IfValid; /** * Get the quarter * * @example DateTime.local(2017, 5, 25).quarter //=> 2 */ get quarter(): IfValid; /** * Get the month (1-12). * * @example DateTime.local(2017, 5, 25).month //=> 5 */ get month(): IfValid; /** * Get the day of the month (1-30ish). * * @example DateTime.local(2017, 5, 25).day //=> 25 */ get day(): IfValid; /** * Get the hour of the day (0-23). * * @example DateTime.local(2017, 5, 25, 9).hour //=> 9 */ get hour(): IfValid; /** * Get the minute of the hour (0-59). * * @example * DateTime.local(2017, 5, 25, 9, 30).minute //=> 30 */ get minute(): IfValid; /** * Get the second of the minute (0-59). * * @example * DateTime.local(2017, 5, 25, 9, 30, 52).second //=> 52 */ get second(): IfValid; /** * Get the millisecond of the second (0-999). * * @example * DateTime.local(2017, 5, 25, 9, 30, 52, 654).millisecond //=> 654 */ get millisecond(): IfValid; /** * Get the week year * @see https://en.wikipedia.org/wiki/ISO_week_date * * @example * DateTime.local(2014, 12, 31).weekYear //=> 2015 */ get weekYear(): IfValid; /** * Get the week number of the week year (1-52ish). * @see https://en.wikipedia.org/wiki/ISO_week_date * * @example * DateTime.local(2017, 5, 25).weekNumber //=> 21 */ get weekNumber(): IfValid; /** * Get the day of the week. * 1 is Monday and 7 is Sunday * @see https://en.wikipedia.org/wiki/ISO_week_date * * @example * DateTime.local(2014, 11, 31).weekday //=> 4 */ get weekday(): IfValid; /** * Returns true if this date is on a weekend, according to the locale, false otherwise */ get isWeekend(): IfValid; /** * Get the day of the week, according to the locale. * 1 is the first day of the week, and 7 is the last day of the week. * If the locale assigns Sunday as the first day of the week, then a date which is a Sunday will return 1. */ get localWeekday(): IfValid; /** * Get the week number of the week year, according to the locale. * Different locales assign week numbers differently. * The week can start on different days of the week (see {@link localWeekday}), * and because a different number of days is required for a week to count as the first week of a year. */ get localWeekNumber(): IfValid; /** * Get the week year, according to the locale. * Different locales assign week numbers (and therefore week years) differently, see {@link localWeekNumber}. */ get localWeekYear(): IfValid; /** * Get the ordinal (meaning the day of the year) * * @example * DateTime.local(2017, 5, 25).ordinal //=> 145 */ get ordinal(): IfValid; /** * Get the human readable short month name, such as 'Oct'. * Defaults to the system's locale if no locale has been specified * * @example * DateTime.local(2017, 10, 30).monthShort //=> Oct */ get monthShort(): IfValid; /** * Get the human readable long month name, such as 'October'. * Defaults to the system's locale if no locale has been specified * * @example * DateTime.local(2017, 10, 30).monthLong //=> October */ get monthLong(): IfValid; /** * Get the human readable short weekday, such as 'Mon'. * Defaults to the system's locale if no locale has been specified * * @example * DateTime.local(2017, 10, 30).weekdayShort //=> Mon */ get weekdayShort(): IfValid; /** * Get the human readable long weekday, such as 'Monday'. * Defaults to the system's locale if no locale has been specified * * @example * DateTime.local(2017, 10, 30).weekdayLong //=> Monday */ get weekdayLong(): IfValid; /** * Get the UTC offset of this DateTime in minutes * * @example * DateTime.now().offset //=> -240 * @example * DateTime.utc().offset //=> 0 */ get offset(): IfValid; /** * Get the short human name for the zone's current offset, for example "EST" or "EDT". * Defaults to the system's locale if no locale has been specified */ get offsetNameShort(): IfValid; /** * Get the long human name for the zone's current offset, for example "Eastern Standard Time" or "Eastern Daylight Time". * Defaults to the system's locale if no locale has been specified */ get offsetNameLong(): IfValid; /** * Get whether this zone's offset ever changes, as in a DST. */ get isOffsetFixed(): IfValid; /** * Get whether the DateTime is in a DST. */ get isInDST(): IfValid; /** * Returns true if this DateTime is in a leap year, false otherwise * * @example * DateTime.local(2016).isInLeapYear //=> true * @example * DateTime.local(2013).isInLeapYear //=> false */ get isInLeapYear(): boolean; /** * Returns the number of days in this DateTime's month * * @example * DateTime.local(2016, 2).daysInMonth //=> 29 * @example * DateTime.local(2016, 3).daysInMonth //=> 31 */ get daysInMonth(): IfValid; /** * Returns the number of days in this DateTime's year * * @example * DateTime.local(2016).daysInYear //=> 366 * @example * DateTime.local(2013).daysInYear //=> 365 */ get daysInYear(): IfValid; /** * Returns the number of weeks in this DateTime's year * @see https://en.wikipedia.org/wiki/ISO_week_date * * @example * DateTime.local(2004).weeksInWeekYear //=> 53 * @example * DateTime.local(2013).weeksInWeekYear //=> 52 */ get weeksInWeekYear(): IfValid; /** * Returns the number of weeks in this DateTime's local week year * * @example * DateTime.local(2020, 6, {locale: 'en-US'}).weeksInLocalWeekYear //=> 52 * @example * DateTime.local(2020, 6, {locale: 'de-DE'}).weeksInLocalWeekYear //=> 53 */ get weeksInLocalWeekYear(): IfValid; /** * Returns the resolved Intl options for this DateTime. * This is useful in understanding the behavior of formatting methods * * @param opts - the same options as toLocaleString */ resolvedLocaleOptions(opts?: LocaleOptions | DateTimeFormatOptions): ResolvedLocaleOptions; // TRANSFORM /** * "Set" the DateTime's zone to UTC. Returns a newly-constructed DateTime. * * Equivalent to {@link DateTime.setZone}('utc') * * @param offset - optionally, an offset from UTC in minutes. Defaults to 0. * @param opts - options to pass to `setZone()`. Defaults to {}. */ toUTC(offset?: number, opts?: ZoneOptions): this; /** * "Set" the DateTime's zone to the host's local zone. Returns a newly-constructed DateTime. * * Equivalent to `setZone('local')` */ toLocal(): this; /** * "Set" the DateTime's zone to specified zone. Returns a newly-constructed DateTime. * * 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, * 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. * * @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'. * You may also supply an instance of a {@link Zone} class. Defaults to 'local'. * @param opts - options * @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. */ setZone(zone?: string | Zone, opts?: ZoneOptions): DateTimeMaybeValid; /** * "Set" the locale, numberingSystem, or outputCalendar. Returns a newly-constructed DateTime. * * @param properties - the properties to set * * @example * DateTime.local(2017, 5, 25).reconfigure({ locale: 'en-GB' }) */ reconfigure(properties: LocaleOptions): this; /** * "Set" the locale. Returns a newly-constructed DateTime. * Just a convenient alias for reconfigure({ locale }) * * @example * DateTime.local(2017, 5, 25).setLocale('en-GB') */ setLocale(locale: string): this; /** * "Set" the values of specified units. Returns a newly-constructed DateTime. * You can only set units with this method; for "setting" metadata, see {@link DateTime.reconfigure} and {@link DateTime.setZone}. * * This method also supports setting locale-based week units, i.e. `localWeekday`, `localWeekNumber` and `localWeekYear`. * They cannot be mixed with ISO-week units like `weekday`. * * @example * dt.set({ year: 2017 }) * @example * dt.set({ hour: 8, minute: 30 }) * @example * dt.set({ weekday: 5 }) * @example * dt.set({ year: 2005, ordinal: 234 }) */ set(values: DateObjectUnits): this; /** * Adding hours, minutes, seconds, or milliseconds increases the timestamp by the right number of milliseconds. Adding days, months, or years shifts the calendar, * 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. * * @param duration - The amount to add. Either a Luxon Duration, a number of milliseconds, the object argument to Duration.fromObject() * * @example * DateTime.now().plus(123) //~> in 123 milliseconds * @example * DateTime.now().plus({ minutes: 15 }) //~> in 15 minutes * @example * DateTime.now().plus({ days: 1 }) //~> this time tomorrow * @example * DateTime.now().plus({ days: -1 }) //~> this time yesterday * @example * DateTime.now().plus({ hours: 3, minutes: 13 }) //~> in 3 hr, 13 min * @example * DateTime.now().plus(Duration.fromObject({ hours: 3, minutes: 13 })) //~> in 3 hr, 13 min */ plus(duration: DurationLike): this; /** * See {@link DateTime.plus} * * @param duration - The amount to subtract. Either a Luxon Duration, a number of milliseconds, the object argument to Duration.fromObject() */ minus(duration: DurationLike): this; /** * "Set" this DateTime to the beginning of the given unit. * * @param unit - The unit to go to the beginning of. Can be 'year', 'quarter', 'month', 'week', 'day', 'hour', 'minute', 'second', or 'millisecond'. * @param opts - options * * @example * DateTime.local(2014, 3, 3).startOf('month').toISODate(); //=> '2014-03-01' * @example * DateTime.local(2014, 3, 3).startOf('year').toISODate(); //=> '2014-01-01' * @example * DateTime.local(2014, 3, 3).startOf('week').toISODate(); //=> '2014-03-03', weeks always start on Mondays * @example * DateTime.local(2014, 3, 3, 5, 30).startOf('day').toISOTime(); //=> '00:00.000-05:00' * @example * DateTime.local(2014, 3, 3, 5, 30).startOf('hour').toISOTime(); //=> '05:00:00.000-05:00' */ startOf(unit: DateTimeUnit, opts?: StartOfOptions): this; /** * "Set" this DateTime to the end (meaning the last millisecond) of a unit of time * * @param unit - The unit to go to the end of. Can be 'year', 'quarter', 'month', 'week', 'day', 'hour', 'minute', 'second', or 'millisecond'. * @param opts - options * * @example * DateTime.local(2014, 3, 3).endOf('month').toISO(); //=> '2014-03-31T23:59:59.999-05:00' * @example * DateTime.local(2014, 3, 3).endOf('year').toISO(); //=> '2014-12-31T23:59:59.999-05:00' * @example * DateTime.local(2014, 3, 3).endOf('week').toISO(); // => '2014-03-09T23:59:59.999-05:00', weeks start on Mondays * @example * DateTime.local(2014, 3, 3, 5, 30).endOf('day').toISO(); //=> '2014-03-03T23:59:59.999-05:00' * @example * DateTime.local(2014, 3, 3, 5, 30).endOf('hour').toISO(); //=> '2014-03-03T05:59:59.999-05:00' */ endOf(unit: DateTimeUnit, opts?: EndOfOptions): this; // OUTPUT /** * Returns a string representation of this DateTime formatted according to the specified format string. * **You may not want this.** See {@link DateTime.toLocaleString} for a more flexible formatting tool. For a table of tokens and their interpretations, * see [here](https://moment.github.io/luxon/#/formatting?id=table-of-tokens). * Defaults to en-US if no locale has been specified, regardless of the system's locale. * * @param format - the format string - see {@link Tokens} * @param options - opts to override the configuration options on this DateTime * * @example * DateTime.now().toFormat('yyyy LLL dd') //=> '2017 Apr 22' * @example * DateTime.now().setLocale('fr').toFormat('yyyy LLL dd') //=> '2017 avr. 22' * @example * DateTime.now().toFormat('yyyy LLL dd', { locale: "fr" }) //=> '2017 avr. 22' * @example * DateTime.now().toFormat("HH 'hours and' mm 'minutes'") //=> '20 hours and 55 minutes' */ toFormat(format: Tokens, options?: LocaleOptions): IfValid; /** * Returns a localized string representing this date. Accepts the same options as the Intl.DateTimeFormat constructor and any presets defined by Luxon, * such as `DateTime.DATE_FULL` or `DateTime.TIME_SIMPLE` of the DateTime in the assigned locale. * Defaults to the system's locale if no locale has been specified * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat * * @param formatOpts - Intl.DateTimeFormat constructor options and configuration options * @param opts - opts to override the configuration options on this DateTime * * @example * DateTime.now().toLocaleString(); //=> 4/20/2017 * @example * DateTime.now().setLocale('en-gb').toLocaleString(); //=> '20/04/2017' * @example * DateTime.now().toLocaleString({ locale: 'en-gb' }); //=> '20/04/2017' * @example * DateTime.now().toLocaleString(DateTime.DATE_FULL); //=> 'April 20, 2017' * @example * DateTime.now().toLocaleString(DateTime.TIME_SIMPLE); //=> '11:32 AM' * @example * DateTime.now().toLocaleString(DateTime.DATETIME_SHORT); //=> '4/20/2017, 11:32 AM' * @example * DateTime.now().toLocaleString({ weekday: 'long', month: 'long', day: '2-digit' }); //=> 'Thursday, April 20' * @example * DateTime.now().toLocaleString({ weekday: 'short', month: 'short', day: '2-digit', hour: '2-digit', minute: '2-digit' }); //=> 'Thu, Apr 20, 11:27 AM' * @example * DateTime.now().toLocaleString({ hour: '2-digit', minute: '2-digit', hourCycle: 'h23' }); //=> '11:32' */ toLocaleString( formatOpts?: DateTimeFormatOptions, opts?: LocaleOptions, ): IfValid; /** * 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. * Defaults to the system's locale if no locale has been specified * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/formatToParts * * @example * DateTime.now().toLocaleParts(); //=> [ * //=> { type: 'day', value: '25' }, * //=> { type: 'literal', value: '/' }, * //=> { type: 'month', value: '05' }, * //=> { type: 'literal', value: '/' }, * //=> { type: 'year', value: '1982' } * //=> ] * @example * DateTime.invalid('').toLocaleParts(); //=> [] */ toLocaleParts(opts?: DateTimeFormatOptions): Intl.DateTimeFormatPart[]; /** * Returns an ISO 8601-compliant string representation of this DateTime * * @example * DateTime.utc(1982, 5, 25).toISO() //=> '1982-05-25T00:00:00.000Z' * @example * DateTime.now().toISO() //=> '2017-04-22T20:47:05.335-04:00' * @example * DateTime.now().toISO({ includeOffset: false }) //=> '2017-04-22T20:47:05.335' * @example * DateTime.now().toISO({ format: 'basic' }) //=> '20170422T204705.335-0400' * @example * DateTime.now().toISO({ precision: 'day' }) //=> '2017-04-22Z' * @example * DateTime.now().toISO({ precision: 'minute' }) //=> '2017-04-22T20:47Z' */ toISO(opts?: ToISOTimeOptions): IfValid; /** * Returns an ISO 8601-compliant string representation of this DateTime's date component * * @example * DateTime.utc(1982, 5, 25).toISODate() //=> '1982-05-25' * @example * DateTime.utc(1982, 5, 25).toISODate({ format: 'basic' }) //=> '19820525' * @example * DateTime.utc(1982, 5, 25).toISODate({ precision: 'month' }) //=> '1982-05' */ toISODate(opts?: ToISODateOptions): IfValid; /** * Returns an ISO 8601-compliant string representation of this DateTime's week date * * @example * DateTime.utc(1982, 5, 25).toISOWeekDate() //=> '1982-W21-2' */ toISOWeekDate(): IfValid; /** * Returns an ISO 8601-compliant string representation of this DateTime's time component * * @example * DateTime.utc().set({ hour: 7, minute: 34 }).toISOTime() //=> '07:34:19.361Z' * @example * DateTime.utc().set({ hour: 7, minute: 34, seconds: 0, milliseconds: 0 }).toISOTime({ suppressSeconds: true }) //=> '07:34Z' * @example * DateTime.utc().set({ hour: 7, minute: 34 }).toISOTime({ format: 'basic' }) //=> '073419.361Z' * @example * DateTime.utc().set({ hour: 7, minute: 34 }).toISOTime({ includePrefix: true }) //=> 'T07:34:19.361Z' * @example * DateTime.utc().set({ hour: 7, minute: 34, second: 56 }).toISOTime({ precision: 'minute' }) //=> '07:34Z' */ toISOTime(opts?: ToISOTimeOptions): IfValid; /** * Returns an RFC 2822-compatible string representation of this DateTime, always in UTC * * @example * DateTime.utc(2014, 7, 13).toRFC2822() //=> 'Sun, 13 Jul 2014 00:00:00 +0000' * @example * DateTime.local(2014, 7, 13).toRFC2822() //=> 'Sun, 13 Jul 2014 00:00:00 -0400' */ toRFC2822(): IfValid; /** * Returns a string representation of this DateTime appropriate for use in HTTP headers. * Specifically, the string conforms to RFC 1123. * @see https://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3.1 * * @example * DateTime.utc(2014, 7, 13).toHTTP() //=> 'Sun, 13 Jul 2014 00:00:00 GMT' * @example * DateTime.utc(2014, 7, 13, 19).toHTTP() //=> 'Sun, 13 Jul 2014 19:00:00 GMT' */ toHTTP(): IfValid; /** * Returns a string representation of this DateTime appropriate for use in SQL Date * * @example * DateTime.utc(2014, 7, 13).toSQLDate() //=> '2014-07-13' */ toSQLDate(): IfValid; /** * Returns a string representation of this DateTime appropriate for use in SQL Time * * @example * DateTime.utc().toSQL() //=> '05:15:16.345' * @example * DateTime.now().toSQL() //=> '05:15:16.345 -04:00' * @example * DateTime.now().toSQL({ includeOffset: false }) //=> '05:15:16.345' * @example * DateTime.now().toSQL({ includeZone: false }) //=> '05:15:16.345 America/New_York' */ toSQLTime(opts?: ToSQLOptions): IfValid; /** * Returns a string representation of this DateTime for use in SQL DateTime * * @example * DateTime.utc(2014, 7, 13).toSQL() //=> '2014-07-13 00:00:00.000 Z' * @example * DateTime.local(2014, 7, 13).toSQL() //=> '2014-07-13 00:00:00.000 -04:00' * @example * DateTime.local(2014, 7, 13).toSQL({ includeOffset: false }) //=> '2014-07-13 00:00:00.000' * @example * DateTime.local(2014, 7, 13).toSQL({ includeZone: true }) //=> '2014-07-13 00:00:00.000 America/New_York' */ toSQL(opts?: ToSQLOptions): IfValid; /** * Returns a string representation of this DateTime appropriate for debugging */ toString(): IfValid; /** * Returns the epoch milliseconds of this DateTime. Alias of {@link DateTime.toMillis} */ valueOf(): IfValid; /** * Returns the epoch milliseconds of this DateTime. */ toMillis(): IfValid; /** * Returns the epoch seconds of this DateTime. */ toSeconds(): IfValid; /** * Returns the epoch seconds (as a whole number) of this DateTime. */ toUnixInteger(): IfValid; /** * Returns an ISO 8601 representation of this DateTime appropriate for use in JSON. */ toJSON(): IfValid; /** * Returns a BSON-serializable equivalent to this DateTime. */ toBSON(): Date; /** * Returns a JavaScript object with this DateTime's year, month, day, and so on. * * @param opts - options for generating the object * @param opts.includeConfig - include configuration attributes in the output. Defaults to false. * * @example * DateTime.now().toObject() //=> { year: 2017, month: 4, day: 22, hour: 20, minute: 49, second: 42, millisecond: 268 } */ toObject(opts?: { /** * Include configuration attributes in the output * @defaultValue false */ includeConfig?: IncludeConfig; }): ToObjectOutput; /** * Returns a JavaScript Date equivalent to this DateTime. */ toJSDate(): Date; // COMPARE /** * Return the difference between two DateTimes as a Duration. * * @param otherDateTime - the DateTime to compare this one to * @param unit - the unit or array of units to include in the duration. * Defaults to ['milliseconds']. * @param opts - options that affect the creation of the Duration * @param opts.conversionAccuracy - the conversion system to use. * Defaults to 'casual'. * * @example * let i1 = DateTime.fromISO('1982-05-25T09:45'), * i2 = DateTime.fromISO('1983-10-14T10:30'); * i2.diff(i1).toObject() //=> { milliseconds: 43807500000 } * i2.diff(i1, 'hours').toObject() //=> { hours: 12168.75 } * i2.diff(i1, ['months', 'days']).toObject() //=> { months: 16, days: 19.03125 } * i2.diff(i1, ['months', 'days', 'hours']).toObject() //=> { months: 16, days: 19, hours: 0.75 } */ diff(otherDateTime: DateTime, unit?: DurationUnits, opts?: DiffOptions): Duration; /** * Return the difference between this DateTime and right now. * See {@link DateTime.diff} * * @param unit - the unit(s) to include in the duration. Defaults to ['milliseconds']. * @param opts - options that affect the creation of the Duration * @param opts.conversionAccuracy - the conversion system to use. Defaults to 'casual'. */ diffNow(unit?: DurationUnits, opts?: DiffOptions): Duration; /** * Return an Interval spanning between this DateTime and another DateTime * * @param otherDateTime - the other end point of the Interval */ until(otherDateTime: DateTime): IfValid, DateTime, IsValid>; /** * Return whether this DateTime is in the same unit of time as another DateTime. * 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. * * @param otherDateTime - the other DateTime * @param unit - the unit of time to check sameness on * * @example * DateTime.now().hasSame(otherDT, 'day'); //~> true if otherDT is in the same current calendar day */ hasSame(otherDateTime: DateTime, unit: DateTimeUnit, opts?: HasSameOptions): IfValid; /** * An equality check. * Two DateTimes are equal if and only if they represent the same millisecond, have the same zone and location, and are both valid. * To compare just the millisecond values, use `+dt1 === +dt2`. * * @param other - the other DateTime */ equals(other: DateTime): IfValid; /** * Returns a string representation of this time relative to now, such as "in two days". * Can only internationalize if your platform supports Intl.RelativeTimeFormat. * Rounds towards zero by default. * * @example * DateTime.now().plus({ days: 1 }).toRelative() //=> "in 1 day" * @example * DateTime.now().setLocale("es").toRelative({ days: 1 }) //=> "dentro de 1 día" * @example * DateTime.now().plus({ days: 1 }).toRelative({ locale: "fr" }) //=> "dans 23 heures" * @example * DateTime.now().minus({ days: 2 }).toRelative() //=> "2 days ago" * @example * DateTime.now().minus({ days: 2 }).toRelative({ unit: "hours" }) //=> "48 hours ago" * @example * DateTime.now().minus({ hours: 36 }).toRelative({ round: false }) //=> "1.5 days ago" */ toRelative(options?: ToRelativeOptions): IfValid; /** * Returns a string representation of this date relative to today, such as "yesterday" or "next month". * Only internationalizes on platforms that support Intl.RelativeTimeFormat. * * @example * DateTime.now().plus({ days: 1 }).toRelativeCalendar() //=> "tomorrow" * @example * DateTime.now().setLocale("es").plus({ days: 1 }).toRelative() //=> ""mañana" * @example * DateTime.now().plus({ days: 1 }).toRelativeCalendar({ locale: "fr" }) //=> "demain" * @example * DateTime.now().minus({ days: 2 }).toRelativeCalendar() //=> "2 days ago" */ toRelativeCalendar(options?: ToRelativeCalendarOptions): IfValid; /** * Return the min of several date times * * @param dateTimes - the DateTimes from which to choose the minimum */ static min(...dateTimes: Values): PickedDateTime; /** * Return the max of several date times * * @param dateTimes - the DateTimes from which to choose the maximum */ static max(...dateTimes: Values): PickedDateTime; // MISC /** * Explain how a string would be parsed by {@link fromFormat} * * @param text - the string to parse * @param format - the format the string is expected to be in - see {@link Tokens} * @param options - options taken by {@link fromFormat} */ static fromFormatExplain(text: string, format: Tokens, options?: DateTimeOptions): ExplainedFormat; /** * @deprecated use {@link fromFormatExplain} instead */ static fromStringExplain(text: string, format: Tokens, options?: DateTimeOptions): ExplainedFormat; /** * Build a parser for a given format using the given locale. * * This parser can be passed to {@link fromFormatParser} to a parse a date in this format. * This can be used to optimize cases where many dates need to be parsed in a specific format. * * @param format - the format the string is expected to be in - see {@link Tokens} * @param options - the Locale options */ static buildFormatParser(format: Tokens, options?: LocaleOptions): TokenParser; /** * Create a DateTime from an input string and format parser. * * The format parser must have been created with the same locale as this call. * * @param text the string to parse * @param parser - parser from {@link buildFormatParser} * @param options options taken by {@link fromFormat} */ static fromFormatParser(text: string, parser: TokenParser, options?: DateTimeOptions): DateTimeMaybeValid; // FORMAT PRESETS /** * {@link DateTime.toLocaleString} format like 10/14/1983 */ static get DATE_SHORT(): Intl.DateTimeFormatOptions; /** * {@link DateTime.toLocaleString} format like 'Oct 14, 1983' */ static get DATE_MED(): Intl.DateTimeFormatOptions; /** * {@link DateTime.toLocaleString} format like 'Fri, Oct 14, 1983' */ static get DATE_MED_WITH_WEEKDAY(): Intl.DateTimeFormatOptions; /** * {@link DateTime.toLocaleString} format like 'October 14, 1983' */ static get DATE_FULL(): Intl.DateTimeFormatOptions; /** * {@link DateTime.toLocaleString} format like 'Tuesday, October 14, 1983' */ static get DATE_HUGE(): Intl.DateTimeFormatOptions; /** * {@link DateTime.toLocaleString} format like '09:30 AM'. Only 12-hour if the locale is. */ static get TIME_SIMPLE(): Intl.DateTimeFormatOptions; /** * {@link DateTime.toLocaleString} format like '09:30:23 AM'. Only 12-hour if the locale is. */ static get TIME_WITH_SECONDS(): Intl.DateTimeFormatOptions; /** * {@link DateTime.toLocaleString} format like '09:30:23 AM EDT'. Only 12-hour if the locale is. */ static get TIME_WITH_SHORT_OFFSET(): Intl.DateTimeFormatOptions; /** * {@link DateTime.toLocaleString} format like '09:30:23 AM Eastern Daylight Time'. Only 12-hour if the locale is. */ static get TIME_WITH_LONG_OFFSET(): Intl.DateTimeFormatOptions; /** * {@link DateTime.toLocaleString} format like '09:30', always 24-hour. */ static get TIME_24_SIMPLE(): Intl.DateTimeFormatOptions; /** * {@link DateTime.toLocaleString} format like '09:30:23', always 24-hour. */ static get TIME_24_WITH_SECONDS(): Intl.DateTimeFormatOptions; /** * {@link DateTime.toLocaleString} format like '09:30:23 EDT', always 24-hour. */ static get TIME_24_WITH_SHORT_OFFSET(): Intl.DateTimeFormatOptions; /** * {@link DateTime.toLocaleString} format like '09:30:23 Eastern Daylight Time', always 24-hour. */ static get TIME_24_WITH_LONG_OFFSET(): Intl.DateTimeFormatOptions; /** * {@link DateTime.toLocaleString} format like '10/14/1983, 9:30 AM'. Only 12-hour if the locale is. */ static get DATETIME_SHORT(): Intl.DateTimeFormatOptions; /** * {@link DateTime.toLocaleString} format like '10/14/1983, 9:30:33 AM'. Only 12-hour if the locale is. */ static get DATETIME_SHORT_WITH_SECONDS(): Intl.DateTimeFormatOptions; /** * {@link DateTime.toLocaleString} format like 'Oct 14, 1983, 9:30 AM'. Only 12-hour if the locale is. */ static get DATETIME_MED(): Intl.DateTimeFormatOptions; /** * {@link DateTime.toLocaleString} format like 'Oct 14, 1983, 9:30:33 AM'. Only 12-hour if the locale is. */ static get DATETIME_MED_WITH_SECONDS(): Intl.DateTimeFormatOptions; /** * {@link DateTime.toLocaleString} format like 'Fri, 14 Oct 1983, 9:30 AM'. Only 12-hour if the locale is. */ static get DATETIME_MED_WITH_WEEKDAY(): Intl.DateTimeFormatOptions; /** * {@link DateTime.toLocaleString} format like 'October 14, 1983, 9:30 AM EDT'. Only 12-hour if the locale is. */ static get DATETIME_FULL(): Intl.DateTimeFormatOptions; /** * {@link DateTime.toLocaleString} format like 'October 14, 1983, 9:30:33 AM EDT'. Only 12-hour if the locale is. */ static get DATETIME_FULL_WITH_SECONDS(): Intl.DateTimeFormatOptions; /** * {@link DateTime.toLocaleString} format like 'Friday, October 14, 1983, 9:30 AM Eastern Daylight Time'. Only 12-hour if the locale is. */ static get DATETIME_HUGE(): Intl.DateTimeFormatOptions; /** * {@link DateTime.toLocaleString} format like 'Friday, October 14, 1983, 9:30:33 AM Eastern Daylight Time'. Only 12-hour if the locale is. */ static get DATETIME_HUGE_WITH_SECONDS(): Intl.DateTimeFormatOptions; } declare type DateTimeFormatOptions = Intl.DateTimeFormatOptions; declare type DateTimeJSOptions = Omit; declare type DateTimeMaybeValid = CanBeInvalid extends true ? (DateTime | DateTime) : DateTime; declare interface DateTimeOptions extends LocaleOptions { /** * Use this zone if no offset is specified in the input string itself. Will also convert the time to this zone. * @default local */ zone?: string | Zone | undefined; /** * Override the zone with a fixed-offset zone specified in the string itself, if it specifies one. * @default false */ setZone?: boolean | undefined; } declare type DateTimeUnit = "year" | "quarter" | "month" | "week" | "day" | "hour" | "minute" | "second" | "millisecond"; declare type DayNumbers = | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31; declare type DefaultValidity = CanBeInvalid extends true ? boolean : true; declare interface DiffOptions { /** * @default 'casual' */ conversionAccuracy?: ConversionAccuracy | undefined; } /** * A Duration object represents a period of time, like "2 months" or "1 day, 1 hour". * Conceptually, it is just a map of units to their quantities, accompanied by some additional configuration and methods for creating, parsing, interrogating, transforming, and formatting them. * They can be used on their own or in conjunction with other Luxon types; for example, you can use {@link DateTime.plus} to add a Duration object to a DateTime, producing another DateTime. * * Here is a brief overview of commonly used methods and getters in Duration: * * * **Creation** To create a Duration, use {@link Duration.fromMillis}, {@link Duration.fromObject}, or {@link Duration.fromISO}. * * **Unit values** See the {@link Duration#years}, {@link Duration.months}, {@link Duration#weeks}, {@link Duration#days}, {@link Duration#hours}, {@link Duration#minutes}, * * {@link Duration#seconds}, {@link Duration#milliseconds} accessors. * * **Configuration** See {@link Duration#locale} and {@link Duration#numberingSystem} accessors. * * **Transformation** To create new Durations out of old ones use {@link Duration#plus}, {@link Duration#minus}, {@link Duration#normalize}, {@link Duration#set}, {@link Duration#reconfigure}, * * {@link Duration#shiftTo}, and {@link Duration#negate}. * * **Output** To convert the Duration into other representations, see {@link Duration#as}, {@link Duration#toISO}, {@link Duration#toFormat}, and {@link Duration#toJSON} * * There's are more methods documented below. In addition, for more information on subtler topics like internationalization and validity, see the external documentation. */ declare class Duration { /** * Create Duration from a number of milliseconds. * * @param count - of milliseconds * @param opts - options for parsing * @param opts.locale - the locale to use * @param opts.numberingSystem - the numbering system to use * @param opts.conversionAccuracy - the conversion system to use */ static fromMillis(count: number, opts?: DurationOptions): Duration; /** * Create a Duration from a JavaScript object with keys like 'years' and 'hours'. * If this object is empty then a zero milliseconds duration is returned. * * @param obj - the object to create the Duration from * @param obj.years * @param obj.quarters * @param obj.months * @param obj.weeks * @param obj.days * @param obj.hours * @param obj.minutes * @param obj.seconds * @param obj.milliseconds * @param opts - options for creating this Duration. Defaults to {}. * @param opts.locale - the locale to use. Defaults to 'en-US'. * @param opts.numberingSystem - the numbering system to use * @param opts.conversionAccuracy - the conversion system to use. Defaults to 'casual'. */ static fromObject(obj: DurationLikeObject, opts?: DurationOptions): Duration; /** * Create a Duration from DurationLike. * * @param durationLike * Either a Luxon Duration, a number of milliseconds, or the object argument to Duration.fromObject() */ static fromDurationLike(durationLike: DurationLike): Duration; /** * Create a Duration from an ISO 8601 duration string. * @see https://en.wikipedia.org/wiki/ISO_8601#Durations * * @param text - text to parse * @param opts - options for parsing * @param opts.locale - the locale to use. Defaults to 'en-US'. * @param opts.numberingSystem - the numbering system to use * @param opts.conversionAccuracy - the conversion system to use. Defaults to 'casual'. * * @example * Duration.fromISO('P3Y6M1W4DT12H30M5S').toObject() //=> { years: 3, months: 6, weeks: 1, days: 4, hours: 12, minutes: 30, seconds: 5 } * @example * Duration.fromISO('PT23H').toObject() //=> { hours: 23 } * @example * Duration.fromISO('P5Y3M').toObject() //=> { years: 5, months: 3 } */ static fromISO(text: string, opts?: DurationOptions): DurationMaybeValid; /** * Create a Duration from an ISO 8601 time string. * @see https://en.wikipedia.org/wiki/ISO_8601#Times * * @param text - text to parse * @param opts - options for parsing * @param opts.locale - the locale to use. Defaults to 'en-US'. * @param opts.numberingSystem - the numbering system to use * @param opts.conversionAccuracy - the conversion system to use. Defaults to 'casual'. * * @example * Duration.fromISOTime('11:22:33.444').toObject() //=> { hours: 11, minutes: 22, seconds: 33, milliseconds: 444 } * @example * Duration.fromISOTime('11:00').toObject() //=> { hours: 11, minutes: 0, seconds: 0 } * @example * Duration.fromISOTime('T11:00').toObject() //=> { hours: 11, minutes: 0, seconds: 0 } * @example * Duration.fromISOTime('1100').toObject() //=> { hours: 11, minutes: 0, seconds: 0 } * @example * Duration.fromISOTime('T1100').toObject() //=> { hours: 11, minutes: 0, seconds: 0 } */ static fromISOTime(text: string, opts?: DurationOptions): DurationMaybeValid; /** * Create an invalid Duration. * * @param reason - simple string of why this datetime is invalid. Should not contain parameters or anything else data-dependent * @param explanation - longer explanation, may include parameters and other useful debugging information. Defaults to null. */ static invalid(reason: string, explanation?: string): Duration; /** * Check if an object is a Duration. Works across context boundaries * * @param o */ static isDuration(o: unknown): o is DurationMaybeValid; private constructor(config: unknown); /** * Get the locale of a Duration, such as 'en-GB' */ get locale(): IfValid; /** * Get the numbering system of a Duration, such as 'beng'. The numbering system is used when formatting the Duration */ get numberingSystem(): IfValid; /** * Returns a string representation of this Duration formatted according to the specified format string. You may use these tokens: * * `S` for milliseconds * * `s` for seconds * * `m` for minutes * * `h` for hours * * `d` for days * * `M` for months * * `y` for years * Notes: * * Add padding by repeating the token, e.g. "yy" pads the years to two digits, "hhhh" pads the hours out to four digits * * The duration will be converted to the set of units in the format string using {@link Duration.shiftTo} and the Duration's conversion accuracy setting. * * @example * Duration.fromObject({ years: 1, days: 6, seconds: 2 }).toFormat("y d s") //=> "1 6 2" * @example * Duration.fromObject({ years: 1, days: 6, seconds: 2 }).toFormat("yy dd sss") //=> "01 06 002" * @example * Duration.fromObject({ years: 1, days: 6, seconds: 2 }).toFormat("M S") //=> "12 518402000" * @example * Duration.fromObject({ days: 6, seconds: 2 }).toFormat("d s", { signMode: "all" }) //=> "+6 +2" * @example * Duration.fromObject({ days: -6, seconds: -2 }).toFormat("d s", { signMode: "all" }) //=> "-6 -2" * @example * Duration.fromObject({ days: -6, seconds: -2 }).toFormat("d s", { signMode: "negativeLargestOnly" }) //=> "-6 2" */ toFormat(fmt: string, opts?: DurationFormatOptions): IfValid; /** * Returns a string representation of a Duration with all units included * To modify its behavior use the `listStyle` and any Intl.NumberFormat option, though `unitDisplay` is especially relevant. See {@link Intl.NumberFormat}. * * @example * ```js * var dur = Duration.fromObject({ months: 1, weeks: 0, hours: 5, minutes: 6 }) * dur.toHuman() //=> '1 month, 0 weeks, 5 hours, 6 minutes' * dur.toHuman({ listStyle: "long" }) //=> '1 month, 0 weeks, 5 hours, and 6 minutes' * dur.toHuman({ unitDisplay: "short" }) //=> '1 mth, 0 wks, 5 hr, 6 min' * dur.toHuman({ showZeros: false }) //=> '1 month, 5 hours, 6 minutes' * ``` */ toHuman(opts?: ToHumanDurationOptions): string; /** * Returns a JavaScript object with this Duration's values. * * @example * Duration.fromObject({ years: 1, days: 6, seconds: 2 }).toObject() //=> { years: 1, days: 6, seconds: 2 } */ toObject(): DurationObjectUnits; /** * Returns an ISO 8601-compliant string representation of this Duration. * @see https://en.wikipedia.org/wiki/ISO_8601#Durations * * @example * Duration.fromObject({ years: 3, seconds: 45 }).toISO() //=> 'P3YT45S' * @example * Duration.fromObject({ months: 4, seconds: 45 }).toISO() //=> 'P4MT45S' * @example * Duration.fromObject({ months: 5 }).toISO() //=> 'P5M' * @example * Duration.fromObject({ minutes: 5 }).toISO() //=> 'PT5M' * @example * Duration.fromObject({ milliseconds: 6 }).toISO() //=> 'PT0.006S' */ toISO(): IfValid; /** * Returns an ISO 8601-compliant string representation of this Duration, formatted as a time of day. * @see https://en.wikipedia.org/wiki/ISO_8601#Times * * @param opts - options * @param opts.suppressMilliseconds - exclude milliseconds from the format if they are 0. Defaults to false. * @param opts.suppressSeconds - exclude seconds from the format if they're 0. Defaults to false. * @param opts.includePrefix - include the `T` prefix. Defaults to false. * @param opts.format - choose between the basic and extended format. Defaults to 'extended'. * * @example * Duration.fromObject({ hours: 11 }).toISOTime() //=> '11:00:00.000' * @example * Duration.fromObject({ hours: 11 }).toISOTime({ suppressMilliseconds: true }) //=> '11:00:00' * @example * Duration.fromObject({ hours: 11 }).toISOTime({ suppressSeconds: true }) //=> '11:00' * @example * Duration.fromObject({ hours: 11 }).toISOTime({ includePrefix: true }) //=> 'T11:00:00.000' * @example * Duration.fromObject({ hours: 11 }).toISOTime({ format: 'basic' }) //=> '110000.000' */ toISOTime(opts?: ToISOTimeDurationOptions): IfValid; /** * Returns an ISO 8601 representation of this Duration appropriate for use in JSON. */ toJSON(): IfValid; /** * Returns an ISO 8601 representation of this Duration appropriate for use in debugging. */ toString(): IfValid; /** * Returns a millisecond value of this Duration. */ toMillis(): IfValid; /** * Returns a millisecond value of this Duration. Alias of {@link toMillis} */ valueOf(): IfValid; /** * Make this Duration longer by the specified amount. Return a newly-constructed Duration. * * @param duration - The amount to add. Either a Luxon Duration, a number of milliseconds, the object argument to Duration.fromObject() */ plus(duration: DurationLike): this; /** * Make this Duration shorter by the specified amount. Return a newly-constructed Duration. * * @param duration - The amount to subtract. Either a Luxon Duration, a number of milliseconds, the object argument to Duration.fromObject() */ minus(duration: DurationLike): this; /** * Scale this Duration by the specified amount. Return a newly-constructed Duration. * * @example * Duration.fromObject({ hours: 1, minutes: 30 }).mapUnit(x => x * 2) //=> { hours: 2, minutes: 60 } * @example * Duration.fromObject({ hours: 1, minutes: 30 }).mapUnit((x, u) => u === "hour" ? x * 2 : x) //=> { hours: 2, minutes: 30 } */ mapUnits(fn: (x: number, u?: DurationUnit) => number): this; /** * Get the value of unit. * * @param unit - a unit such as 'minute' or 'day' * * @example * Duration.fromObject({years: 2, days: 3}).get('years') //=> 2 * @example * Duration.fromObject({years: 2, days: 3}).get('months') //=> 0 * @example * Duration.fromObject({years: 2, days: 3}).get('days') //=> 3 */ get(unit: DurationUnit): IfValid; /** * "Set" the values of specified units. Return a newly-constructed Duration. * * @param values - a mapping of units to numbers * * @example * dur.set({ years: 2017 }) * @example * dur.set({ hours: 8, minutes: 30 }) */ set(values: DurationLikeObject): this; /** * "Set" the locale and/or numberingSystem. Returns a newly-constructed Duration. * * @example * dur.reconfigure({ locale: 'en-GB' }) */ reconfigure(opts?: DurationOptions): this; /** * Return the length of the duration in the specified unit. * * @param unit - a unit such as 'minutes' or 'days' * * @example * Duration.fromObject({years: 1}).as('days') //=> 365 * @example * Duration.fromObject({years: 1}).as('months') //=> 12 * @example * Duration.fromObject({hours: 60}).as('days') //=> 2.5 */ as(unit: DurationUnit): IfValid; /** * Reduce this Duration to its canonical representation in its current units. * * @example * Duration.fromObject({ years: 2, days: 5000 }).normalize().toObject() //=> { years: 15, days: 255 } * @example * Duration.fromObject({ hours: 12, minutes: -45 }).normalize().toObject() //=> { hours: 11, minutes: 15 } */ normalize(): this; /** * Rescale units to its largest representation. * * @example * Duration.fromObject({ milliseconds: 90000 }).rescale().toObject() //=> { minutes: 1, seconds: 30 } */ rescale(): this; /** * Convert this Duration into its representation in a different set of units. * * @example * Duration.fromObject({ hours: 1, seconds: 30 }).shiftTo('minutes', 'milliseconds').toObject() //=> { minutes: 60, milliseconds: 30000 } */ shiftTo(...units: DurationUnit[]): this; /** * Shift this Duration to all available units. * Same as shiftTo("years", "months", "weeks", "days", "hours", "minutes", "seconds", "milliseconds") */ shiftToAll(): this; /** * Return the negative of this Duration. * * @example * Duration.fromObject({ hours: 1, seconds: 30 }).negate().toObject() //=> { hours: -1, seconds: -30 } */ negate(): this; /** * Removes all units with values equal to 0 from this Duration. * * @example * Duration.fromObject({ years: 2, days: 0, hours: 0, minutes: 0 }).removeZeros().toObject() //=> { years: 2 } */ removeZeros(): this; /** * Get the years. */ get years(): IfValid; /** * Get the quarters. */ get quarters(): IfValid; /** * Get the months. */ get months(): IfValid; /** * Get the weeks */ get weeks(): IfValid; /** * Get the days. */ get days(): IfValid; /** * Get the hours. */ get hours(): IfValid; /** * Get the minutes. */ get minutes(): IfValid; /** * Get the seconds. */ get seconds(): IfValid; /** * Get the milliseconds. */ get milliseconds(): IfValid; /** * Returns whether the Duration is invalid. * Diff operations on invalid DateTimes or Intervals return invalid Durations. */ get isValid(): IfValid; /** * Returns an error code if this Duration became invalid, or null if the Duration is valid */ get invalidReason(): IfValid; /** * Returns an explanation of why this Duration became invalid, or null if the Duration is valid */ get invalidExplanation(): IfValid; /** * Equality check * Two Durations are equal iff they have the same units and the same values for each unit. */ equals(other: Duration): IfValid; } declare interface DurationFormatOptions { /** * Whether or not to floor numerical values. * @default true */ floor?: boolean | undefined; /** * How to handle signs * @default 'negative' */ signMode?: "negative" | "all" | "negativeLargestOnly" | undefined; } /** * Either a Luxon Duration, a number of milliseconds, the object argument to Duration.fromObject() */ declare type DurationLike = Duration | DurationLikeObject | number; declare interface DurationLikeObject extends DurationObjectUnits { year?: number | undefined; quarter?: number | undefined; month?: number | undefined; week?: number | undefined; day?: number | undefined; hour?: number | undefined; minute?: number | undefined; second?: number | undefined; millisecond?: number | undefined; } declare type DurationMaybeValid = CanBeInvalid extends true ? (Duration | Duration) : Duration; declare interface DurationObjectUnits { years?: number | undefined; quarters?: number | undefined; months?: number | undefined; weeks?: number | undefined; days?: number | undefined; hours?: number | undefined; minutes?: number | undefined; seconds?: number | undefined; milliseconds?: number | undefined; } declare interface DurationOptions { locale?: string | undefined; numberingSystem?: NumberingSystem | undefined; conversionAccuracy?: ConversionAccuracy | undefined; } declare type DurationUnit = keyof DurationLikeObject; declare type DurationUnits = DurationUnit | DurationUnit[]; declare type EndOfOptions = _UseLocaleWeekOption; declare interface ExplainedFormat { input: string; tokens: Array<{ literal: boolean; val: string }>; regex?: RegExp | undefined; rawMatches?: RegExpMatchArray | null | undefined; matches?: { [k: string]: any } | undefined; result?: { [k: string]: any } | null | undefined; zone?: Zone | null | undefined; invalidReason?: string | undefined; } declare type HasSameOptions = _UseLocaleWeekOption; declare type HourNumbers = | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23; declare type IfValid = ThisIsValid extends true ? ValidType : ThisIsValid extends false ? InvalidType : CanBeInvalid extends true ? ValidType | InvalidType : ValidType; /** * An Interval object represents a half-open interval of time, where each endpoint is a {@link DateTime}. * Conceptually, it is a container for those two endpoints, accompanied by methods for * creating, parsing, interrogating, comparing, transforming, and formatting them. * * Here is a brief overview of the most commonly used methods and getters in Interval: * * * **Creation** To create an Interval, use {@link Interval.fromDateTimes}, {@link Interval.after}, {@link Interval.before}, or {@link Interval.fromISO}. * * **Accessors** Use {@link Interval#start} and {@link Interval#end} to get the start and end. * * **Interrogation** To analyze the Interval, use {@link Interval#count}, {@link Interval#length}, {@link Interval#hasSame}, * * {@link Interval#contains}, {@link Interval#isAfter}, or {@link Interval#isBefore}. * * **Transformation** To create other Intervals out of this one, use {@link Interval#set}, {@link Interval#splitAt}, {@link Interval#splitBy}, {@link Interval#divideEqually}, * * {@link Interval.merge}, {@link Interval.xor}, {@link Interval#union}, {@link Interval#intersection}, or {@link Interval#difference}. * * **Comparison** To compare this Interval to another one, use {@link Interval#equals}, {@link Interval#overlaps}, {@link Interval#abutsStart}, {@link Interval#abutsEnd}, {@link Interval#engulfs} * * **Output** To convert the Interval into other representations, see {@link Interval#toString}, {@link Interval#toLocaleString}, {@link Interval#toISO}, {@link Interval#toISODate}, * * {@link Interval#toISOTime}, {@link Interval#toFormat}, and {@link Interval#toDuration}. */ declare class Interval { /** * Create an invalid Interval. * * @param reason - simple string of why this Interval is invalid. Should not contain parameters or anything else data-dependent * @param explanation - longer explanation, may include parameters and other useful debugging information. */ static invalid(reason: string, explanation?: string): Interval; /** * Create an Interval from a start DateTime and an end DateTime. Inclusive of the start but not the end. * * @param start * @param end */ static fromDateTimes(start: DateInput, end: DateInput): IntervalMaybeValid; /** * Create an Interval from a start DateTime and a Duration to extend to. * * @param start * @param duration - the length of the Interval. */ static after(start: DateInput, duration: DurationLike): IntervalMaybeValid; /** * Create an Interval from an end DateTime and a Duration to extend backwards to. * * @param end * @param duration - the length of the Interval. */ static before(end: DateInput, duration: DurationLike): IntervalMaybeValid; /** * Create an Interval from an ISO 8601 string. * Accepts `/`, `/`, and `/` formats. * @see https://en.wikipedia.org/wiki/ISO_8601#Time_intervals * * @param text - the ISO string to parse * @param opts - options to pass {@link DateTime.fromISO} and optionally {@link Duration.fromISO} */ static fromISO(text: string, opts?: DateTimeOptions): IntervalMaybeValid; /** * Check if an object is an Interval. Works across context boundaries * * @param o */ static isInterval(o: unknown): o is IntervalMaybeValid; private constructor(config: unknown); /** * Returns the start of the Interval */ get start(): IfValid, null, IsValid>; /** * Returns the end of the Interval. This is the first instant which is not part of the interval. * (Interval is half-open). */ get end(): IfValid, null, IsValid>; /** * Returns the last DateTime included in the interval (since end is not part of the interval) */ get lastDateTime(): IfValid, null, IsValid>; /** * Returns whether this Interval's end is at least its start, meaning that the Interval isn't 'backwards'. */ get isValid(): IfValid; /** * Returns an error code if this Interval is invalid, or null if the Interval is valid */ get invalidReason(): IfValid; /** * Returns an explanation of why this Interval became invalid, or null if the Interval is valid */ get invalidExplanation(): IfValid; /** * Returns the length of the Interval in the specified unit. * * @param unit - the unit (such as 'hours' or 'days') to return the length in. */ length(unit?: DurationUnit): IfValid; /** * Returns the count of minutes, hours, days, months, or years included in the Interval, even in part. * Unlike {@link Interval#length} this counts sections of the calendar, not periods of time, e.g. specifying 'day' * asks 'what dates are included in this interval?', not 'how many days long is this interval?' * * @param unit - the unit of time to count. Defaults to 'milliseconds'. */ count(unit?: DurationUnit, opts?: CountOptions): IfValid; /** * Returns whether this Interval's start and end are both in the same unit of time * * @param unit - the unit of time to check sameness on */ hasSame(unit: DurationUnit): IfValid; /** * Return whether this Interval has the same start and end DateTimes. */ isEmpty(): boolean; /** * Return whether this Interval's start is after the specified DateTime. * * @param dateTime */ isAfter(dateTime: DateTime): IfValid; /** * Return whether this Interval's end is before the specified DateTime. * * @param dateTime */ isBefore(dateTime: DateTime): IfValid; /** * Return whether this Interval contains the specified DateTime. * * @param dateTime */ contains(dateTime: DateTime): IfValid; /** * "Sets" the start and/or end dates. Returns a newly-constructed Interval. * * @param values - the values to set * @param values.start - the starting DateTime * @param values.end - the ending DateTime */ set(values?: IntervalObject): IntervalMaybeValid; /** * Split this Interval at each of the specified DateTimes * * @param dateTimes - the unit of time to count. */ splitAt(...dateTimes: DateTime[]): IfValid; /** * Split this Interval into smaller Intervals, each of the specified length. * Left over time is grouped into a smaller interval * * @param duration - The length of each resulting interval. */ splitBy(duration: DurationLike): IfValid; /** * Split this Interval into the specified number of smaller intervals. * * @param numberOfParts - The number of Intervals to divide the Interval into. */ divideEqually(numberOfParts: number): IfValid; /** * Return whether this Interval overlaps with the specified Interval */ overlaps(other: Interval): boolean; /** * Return whether this Interval's end is adjacent to the specified Interval's start. */ abutsStart(other: Interval): IfValid; /** * Return whether this Interval's start is adjacent to the specified Interval's end. */ abutsEnd(other: Interval): IfValid; /** * Return whether this Interval engulfs the start and end of the specified Interval. */ engulfs(other: Interval): IfValid; /** * Return whether this Interval has the same start and end as the specified Interval. */ equals(other: Interval): IfValid; /** * Return an Interval representing the intersection of this Interval and the specified Interval. * Specifically, the resulting Interval has the maximum start time and the minimum end time of the two Intervals. * Returns null if the intersection is empty, meaning the intervals do not intersect. */ intersection(other: Interval): Interval | null; /** * Return an Interval representing the union of this Interval and the specified Interval. * Specifically, the resulting Interval has the minimum start time and the maximum end time of the two Intervals. */ union(other: Interval): IntervalMaybeValid; /** * Merge an array of Intervals into an equivalent minimal set of Intervals. * Combines overlapping and adjacent Intervals. */ static merge(intervals: Interval[]): IntervalMaybeValid[]; /** * Return an array of Intervals representing the spans of time that only appear in one of the specified Intervals. */ static xor(intervals: Interval[]): IntervalMaybeValid[]; /** * Return Intervals representing the spans of time in this Interval that not overlap with any of the specified Intervals. */ difference(...intervals: Interval[]): IntervalMaybeValid[]; /** * Returns a string representation of this Interval appropriate for debugging. */ toString(): IfValid; /** * Returns a localized string representing this Interval. Accepts the same options as the * Intl.DateTimeFormat constructor and any presets defined by Luxon, such as * {@link DateTime.DATE_FULL} or {@link DateTime.TIME_SIMPLE}. The exact behavior of this method * is browser-specific, but in general it will return an appropriate representation of the * Interval in the assigned locale. Defaults to the system's locale if no locale has been * specified. * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat * @param formatOpts - Either a DateTime preset or Intl.DateTimeFormat constructor options. Defaults to DateTime.DATE_SHORT * @param opts - Options to override the configuration of the start DateTime. * * @example * Interval.fromISO('2022-11-07T09:00Z/2022-11-08T09:00Z').toLocaleString(); //=> 11/7/2022 – 11/8/2022 * @example * Interval.fromISO('2022-11-07T09:00Z/2022-11-08T09:00Z').toLocaleString(DateTime.DATE_FULL); //=> November 7 – 8, 2022 * @example * Interval.fromISO('2022-11-07T09:00Z/2022-11-08T09:00Z').toLocaleString(DateTime.DATE_FULL, { locale: 'fr-FR' }); //=> 7–8 novembre 2022 * @example * Interval.fromISO('2022-11-07T17:00Z/2022-11-07T19:00Z').toLocaleString(DateTime.TIME_SIMPLE); //=> 6:00 – 8:00 PM * @example * Interval.fromISO("2022-11-07T17:00Z/2022-11-07T19:00Z").toLocaleString({ * weekday: "short", * month: "short", * day: "2-digit", * hour: "2-digit", * minute: "2-digit", * }); //=> Mon, Nov 07, 6:00 – 8:00 p */ toLocaleString( formatOpts?: Intl.DateTimeFormatOptions, opts?: LocaleOptions, ): IfValid; /** * Returns an ISO 8601-compliant string representation of this Interval. * @see https://en.wikipedia.org/wiki/ISO_8601#Time_intervals * * @param opts - The same options as {@link DateTime#toISO} */ toISO(opts?: ToISOTimeOptions): IfValid; /** * Returns an ISO 8601-compliant string representation of the dates in this Interval. * The time components are ignored. * @see https://en.wikipedia.org/wiki/ISO_8601#Time_intervals */ toISODate(): IfValid; /** * Returns an ISO 8601-compliant string representation of the times in this Interval. * The date components are ignored. * @see https://en.wikipedia.org/wiki/ISO_8601#Time_intervals * * @param opts - The same options as {@link DateTime.toISO} */ toISOTime(opts?: ToISOTimeOptions): IfValid; /** * Returns a string representation of this Interval formatted according to the specified format string. * * @param dateFormat - the format string. This string formats the start and end time. See {@link DateTime.toFormat} for details. * @param opts - options * @param opts.separator - a separator to place between the start and end representations. Defaults to ' - '. */ toFormat( dateFormat: string, opts?: { separator?: string | undefined; }, ): IfValid; /** * Return a Duration representing the time spanned by this interval. * * @param unit - the unit or units (such as 'hours' or 'days') to include in the duration. Defaults to ['milliseconds']. * @param opts - options that affect the creation of the Duration * @param opts.conversionAccuracy - the conversion system to use. Defaults to 'casual'. * * @example * Interval.fromDateTimes(dt1, dt2).toDuration().toObject() //=> { milliseconds: 88489257 } * @example * Interval.fromDateTimes(dt1, dt2).toDuration('days').toObject() //=> { days: 1.0241812152777778 } * @example * Interval.fromDateTimes(dt1, dt2).toDuration(['hours', 'minutes']).toObject() //=> { hours: 24, minutes: 34.82095 } * @example * Interval.fromDateTimes(dt1, dt2).toDuration(['hours', 'minutes', 'seconds']).toObject() //=> { hours: 24, minutes: 34, seconds: 49.257 } * @example * Interval.fromDateTimes(dt1, dt2).toDuration('seconds').toObject() //=> { seconds: 88489.257 } */ toDuration(unit?: DurationUnit | DurationUnit[], opts?: DiffOptions): DurationMaybeValid; /** * Run mapFn on the interval start and end, returning a new Interval from the resulting DateTimes * * @example * Interval.fromDateTimes(dt1, dt2).mapEndpoints(endpoint => endpoint.toUTC()) * @example * Interval.fromDateTimes(dt1, dt2).mapEndpoints(endpoint => endpoint.plus({ hours: 2 })) */ mapEndpoints(mapFn: (d: DateTime) => DateTime): IntervalMaybeValid; } declare type IntervalMaybeValid = CanBeInvalid extends true ? (Interval | Interval) : Interval; declare interface IntervalObject { start?: DateTime | undefined; end?: DateTime | undefined; } declare type Invalid = false; /** * Type guard to check if a value is an array * @param value - The value to check * @returns True if the value is an array, false otherwise */ export declare const isArray: (value: unknown) => value is unknown[]; export declare const isBigInt: (value: unknown) => value is bigint; export declare const isBigIntTypedArray: (value: unknown) => value is BigInt64Array | BigUint64Array; export declare const isError: (value: unknown) => value is Error; /** * Checks if a value is an instance of a specific class. * @param value - The value to check * @param type - The name of the class to check against * @returns true if the value is an instance of the specified class, false otherwise */ export declare const isInstanceOf: (value: unknown, type: string, ctor?: new (...args: any[]) => T) => value is T; /** * Type guard to check if a value is a valid Lucid binary value (Uint8Array or Buffer) * @param value - The value to check * @returns True if the value is a LucidBinaryValue, false otherwise */ export declare const isLucidBinaryValue: (value: unknown) => value is Uint8Array | Buffer; /** * Type guard to check if a value is a Luxon DateTime instance * @param value - The value to check * @returns True if the value is a Luxon DateTime, false otherwise */ export declare const isLuxonDateTime: (value: unknown) => value is DateTime; /** * Type guard to check if a value is a Luxon Duration instance * @param value - The value to check * @returns True if the value is a Luxon Duration, false otherwise */ export declare const isLuxonDuration: (value: unknown) => value is Duration; /** * Type guard to check if a value is a Luxon Interval instance * @param value - The value to check * @returns True if the value is a Luxon Interval, false otherwise */ export declare const isLuxonInterval: (value: unknown) => value is Interval; export declare const isLuxonSystemZone: (value: unknown) => value is SystemZone; export declare const isMap: (value: unknown) => value is Map; export declare const isNegativeZero: (value: unknown) => value is -0; export declare const isNumber: (value: unknown) => value is number; /** * Type guard to check if a value is a plain object (not null, not array) * @param value - The value to check * @returns True if the value is a plain object, false otherwise */ export declare const isObject: (value: unknown) => value is { [key: string]: unknown; }; export declare const isPhoneObject: (value: unknown) => value is Phone; export declare const isPrimitive: (value: unknown) => value is string | number | boolean | bigint | null; export declare const isSet: (value: unknown) => value is Set; export declare const isTypedArray: (value: unknown) => value is Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | BigInt64Array | BigUint64Array; export declare const isUniterableObject: (value: unknown) => value is Date | RegExp | ArrayBuffer | DataView | Error; declare interface LocaleOptions { /** * @default system's locale */ locale?: string | undefined; outputCalendar?: CalendarSystem | undefined; numberingSystem?: NumberingSystem | undefined; weekSettings?: WeekSettings | undefined; } declare type ManyDateTimes = Array>; declare type MinuteNumbers = SecondNumbers; declare type MonthNumbers = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12; declare type NumberingSystem = Intl.DateTimeFormatOptions extends { numberingSystem?: infer T } ? T : | "arab" | "arabext" | "bali" | "beng" | "deva" | "fullwide" | "gujr" | "guru" | "hanidec" | "khmr" | "knda" | "laoo" | "latn" | "limb" | "mlym" | "mong" | "mymr" | "orya" | "tamldec" | "telu" | "thai" | "tibt"; /** * The `Phone` class represents a phone number and provides methods to retrieve information about it. * It implements the `PhoneModel` interface. * @implements {PhoneModel} */ declare class Phone implements PhoneModel { #private; /** * The `Phone` class constructor takes a `phone` argument of type `RawPhoneType` and an optional `country` argument of type `RawCountryType`. * It initializes `Phone` instance. * @constructor * @param {RawPhoneType} phone - The phone number to be parsed and validated. * @param {RawCountryType} [country] - The country code of the phone number. If not provided, the country will be guessed based on the phone number. */ constructor(phone: RawPhoneType, country?: RawCountryType); /** * Returns the phone number as a string stripped of all non-numeric characters. * @readonly * @type {string} */ readonly phone: string; /** * Returns the country code of the phone number. * @readonly * @type {CountryOrUnknown} */ readonly country: CountryOrUnknown; /** * Returns whether the phone number uses a valid format for the parsed country or not. * @readonly * @type {boolean} */ readonly valid: boolean; /** * Returns the type of the phone number. * @readonly * @type {PhoneTypes} */ readonly type: PhoneTypes; /** * Returns whether the phone number is a mobile number or not. * @readonly * @type {boolean} */ readonly mobile: boolean; /** * Returns the raw phone number. * @readonly * @type {string} * * @remarks * If the phone number is not a valid phone number, the initial phone number which was passed to the constructor is returned. */ readonly raw: string; /** * Returns the national format of the phone number. * @readonly * @type {string} * * @remarks * If the phone number is not a valid phone number, the initial phone number which was passed to the constructor is returned. */ readonly national: string; /** * Returns the international format of the phone number. * @readonly * @type {string} * * @remarks * If the phone number is not a valid phone number, the initial phone number which was passed to the constructor is returned. */ readonly international: string; /** * Returns the E.164 format of the phone number. * @readonly * @type {string} * * @remarks * If the phone number is not a valid phone number, the initial phone number which was passed to the constructor is returned. */ readonly e164: string; /** * Returns the timezone of the phone number. * @readonly * @type {PossiblePhoneTimezone} */ readonly timezone: PossiblePhoneTimezone; /** * Returns an object representation of the phone number. * @returns {{ * phone: string; * country: string; * valid: boolean; * type: PhoneTypes; * mobile: boolean; * raw: string; * national: string; * international: string; * e164: string; * timezone: PossiblePhoneTimezone; * }} - An object representation of the phone number. */ toObject(): { /** * The phone number as a string stripped of all non-numeric characters. */ phone: string; /** * The country code of the phone number. * @remarks * In cases where the country was not recognized and could not be guessed from the phone number, `'XX'` is used. * @type {CountryOrUnknown} */ country: CountryOrUnknown; /** * Whether the phone number uses a valid format for the parsed country or not. * @type {boolean} */ valid: boolean; /** * The type of the phone number. * @type {PhoneTypes} */ type: "FIXED_LINE" | "MOBILE" | "FIXED_LINE_OR_MOBILE" | "TOLL_FREE" | "PREMIUM_RATE" | "SHARED_COST" | "VOIP" | "PERSONAL_NUMBER" | "PAGER" | "UAN" | "VOICEMAIL" | "UNKNOWN" | "INVALID"; /** * Whether the phone number is possibly a mobile number or not. * @type {boolean} */ mobile: boolean; /** * The phone number as a string stripped of all non-numeric characters. * @type {string} */ raw: string; /** * The phone number as a string in the national format for the parsed country. * @type {string} */ national: string; /** * The phone number as a string in the international format for the parsed country. * @type {string} */ international: string; /** * The phone number as a string in the E.164 format. * @type {string} */ e164: string; /** * The estimated timezone of the phone number based on the phone number's country. It can be either a `CountryTimezone` or `'UTC'`. */ timezone: PossiblePhoneTimezone; }; /** * Returns a JSON representation of the phone number. * @returns {{ * phone: string; * country: string; * valid: boolean; * type: PhoneTypes; * mobile: boolean; * raw: string; * national: string; * international: string; * e164: string; * timezone: PossiblePhoneTimezone; * }} - A JSON-safe representation of the phone number. */ toJSON(): { /** * The phone number as a string stripped of all non-numeric characters. */ phone: string; /** * The country code of the phone number. * @remarks * In cases where the country was not recognized and could not be guessed from the phone number, `'XX'` is used. * @type {CountryOrUnknown} */ country: CountryOrUnknown; /** * Whether the phone number uses a valid format for the parsed country or not. * @type {boolean} */ valid: boolean; /** * The type of the phone number. * @type {PhoneTypes} */ type: "FIXED_LINE" | "MOBILE" | "FIXED_LINE_OR_MOBILE" | "TOLL_FREE" | "PREMIUM_RATE" | "SHARED_COST" | "VOIP" | "PERSONAL_NUMBER" | "PAGER" | "UAN" | "VOICEMAIL" | "UNKNOWN" | "INVALID"; /** * Whether the phone number is possibly a mobile number or not. * @type {boolean} */ mobile: boolean; /** * The phone number as a string stripped of all non-numeric characters. * @type {string} */ raw: string; /** * The phone number as a string in the national format for the parsed country. * @type {string} */ national: string; /** * The phone number as a string in the international format for the parsed country. * @type {string} */ international: string; /** * The phone number as a string in the E.164 format. * @type {string} */ e164: string; /** * The estimated timezone of the phone number based on the phone number's country. It can be either a `CountryTimezone` or `'UTC'`. */ timezone: PossiblePhoneTimezone; }; /** * Returns the E.164 format of the phone number as a string. * @returns {string} - The E.164 format of the phone number. */ toString(): string; /** * Returns a stringified representation of the phone number. * @returns {string} - A string representation of the phone number. */ inspect(): string; /** * Serializes the phone object to an obfuscated string which can be used to recreate the phone object from the `Phone.deserialize` method. * @returns {string} - The serialized phone object. */ serialize(): string; /** * Creates a new phone object from a serialized phone object. * @param serialized The serialized phone object returned from the `Phone.serialize` method. * @returns A Phone instance with the same properties as the original phone object. * @throws An error if the serialized phone object is not valid. */ static deserialize(serialized: string): Phone; } /** * The `PhoneModel` interface represents a phone number object with various properties and methods. * @interface */ declare interface PhoneModel { /** * The `country` property represents the country that was used to create the `Phone` instance. * @type {CountryOrUnknown} * @remarks * * In cases where the country was not recognized and could not be guessed from the phone number, `'XX'` is used. */ country: CountryOrUnknown; /** * The `valid` property represents whether the phone number uses a valid format for the parsed country or not. * @type {boolean} */ valid: boolean; /** * The `type` property represents the type of the phone number. It can be any of the keys of the `PhoneNumberType` object in the `google-libphonenumber` library, or `'INVALID'` if the phone number is not valid. * @type {PhoneTypes} */ type: PhoneTypes; /** * The `mobile` property represents whether the phone number is possibly a mobile phone number or not. * @type {boolean} * @remarks * * This property is `true` if the phone number type is either `'MOBILE'` or `'FIXED_LINE_OR_MOBILE'`. * This covers cases like in the United States and Canada where it is not possible to tell if a phone number is a mobile phone number or not based on the phone number alone. */ mobile: boolean; /** * The `raw` property represents the phone number as a string stripped of all non-numeric characters. * @type {string} */ raw: string; /** * The `national` property represents the phone number as a string in the national format for the parsed country. * @type {string} */ national: string; /** * The `international` property represents the phone number as a string in the international format for the parsed country. * @type {string} */ international: string; /** * The `e164` property represents the phone number as a string in the E.164 format. * @type {string} */ e164: string; /** * The `timezone` property represents the estimated timezone of the phone number based on the phone number's country. It can be either a `CountryTimezone` or `'UTC'`. * @type {PossiblePhoneTimezone} * @remarks * * In cases where the phone number's country has several timezones, the timezone with the greatest population is used. * In cases where the phone number's country is not recognized or has no timezone defined, `'UTC'` is used. */ timezone: PossiblePhoneTimezone; /** * The `toObject` method returns an object with the same properties as the `PhoneModelInstanceObject` interface. * @returns {PhoneModelInstanceObject} */ toObject(): PhoneModelInstanceObject; /** * The `toJSON` method returns an object with the same properties as the `PhoneModelInstanceObject` interface. * @returns {PhoneModelInstanceObject} */ toJSON(): PhoneModelInstanceObject; /** * The `toString` method returns the phone number as a string in the international format for the parsed country. * @returns {string} */ toString(): string; } /** * The `PhoneModelInstanceObject` interface represents the properties of a `Phone` instance. * @interface */ declare interface PhoneModelInstanceObject { /** * The `phone` property represents the raw phone number string that was used to create the `Phone` instance. * @type {string} */ phone: string; /** * The `country` property represents the country that was used to create the `Phone` instance. * @type {CountryOrUnknown} * @remarks * * In cases where the country was not recognized and could not be guessed from the phone number, `'XX'` is used. */ country: CountryOrUnknown; /** * The `valid` property represents whether the phone number uses a valid format for the parsed country or not. * @type {boolean} */ valid: boolean; /** * The `type` property represents the type of the phone number. It can be any of the keys of the `PhoneNumberType` object in the `google-libphonenumber` library, or `'INVALID'` if the phone number is not valid. * @type {PhoneTypes} */ type: PhoneTypes; /** * The `mobile` property represents whether the phone number is possibly a mobile phone number or not. * @type {boolean} * @remarks * * This property is `true` if the phone number type is either `'MOBILE'` or `'FIXED_LINE_OR_MOBILE'`. * This covers cases like in the United States and Canada where it is not possible to tell if a phone number is a mobile phone number or not based on the phone number alone. */ mobile: boolean; /** * The `raw` property represents the phone number as a string stripped of all non-numeric characters. * @type {string} */ raw: string; /** * The `national` property represents the phone number as a string in the national format for the parsed country. * @type {string} */ national: string; /** * The `international` property represents the phone number as a string in the international format for the parsed country. * @type {string} */ international: string; /** * The `e164` property represents the phone number as a string in the E.164 format. * @type {string} */ e164: string; /** * The `timezone` property represents the estimated timezone of the phone number based on the phone number's country. It can be either a `CountryTimezone` or `'UTC'`. * @type {PossiblePhoneTimezone} * @remarks * * In cases where the phone number's country has several timezones, the timezone with the greatest population is used. * In cases where the phone number's country is not recognized or has no timezone defined, `'UTC'` is used. */ timezone: PossiblePhoneTimezone; } /** * The `PhoneTypes` type represents the possible types of a phone number. It can be any of the keys of the `PhoneNumberType` object in the `google-libphonenumber` library, or `'INVALID'` if the phone number is not valid. */ declare const PhoneTypes: readonly ["FIXED_LINE", "MOBILE", "FIXED_LINE_OR_MOBILE", "TOLL_FREE", "PREMIUM_RATE", "SHARED_COST", "VOIP", "PERSONAL_NUMBER", "PAGER", "UAN", "VOICEMAIL", "UNKNOWN", "INVALID"]; /** * The `PhoneTypes` type represents the possible types of a phone number. It can be any of the keys of the `PhoneNumberType` object in the `google-libphonenumber` library, or `'INVALID'` if the phone number is not valid. */ declare type PhoneTypes = (typeof PhoneTypes)[number]; declare type PickedDateTime = Values extends [] ? undefined : | (Values extends Array> ? | (AllValues extends true ? DateTime : never) | (AllValues extends false ? DateTime : never) : never) | ([] extends Values ? undefined : never); declare type PossibleDaysInMonth = 28 | 29 | 30 | 31; declare type PossibleDaysInYear = 365 | 366; /** * The `PossiblePhoneTimezone` type represents the estimated timezone of a phone number based on the phone number's country. It can be either a `CountryTimezone` or `'UTC'`. * @typedef {CountryTimezone | 'UTC'} PossiblePhoneTimezone * @remarks * * In cases where the phone number's country has several timezones, the timezone with the greatest population is used. * In cases where the phone number's country is not recognized or has no timezone defined, `'UTC'` is used. */ declare type PossiblePhoneTimezone = CountryTimezone | 'UTC'; declare type PossibleWeeksInYear = 52 | 53; declare type QuarterNumbers = 1 | 2 | 3 | 4; /** * The `RawCountryType` type represents the country which should be used to parse the phone number. It is of type `Country`. * @typedef {Country} RawCountryType */ declare type RawCountryType = Country; /** * The `RawPhoneType` type represents the phone number which should be parsed. It can be either a string or a number. * @typedef {string | number} RawPhoneType */ declare type RawPhoneType = string | number; declare type ResolvedLocaleOptions = Required; declare type SecondNumbers = | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59; declare type StartOfOptions = _UseLocaleWeekOption; declare type StringUnitLength = "narrow" | "short" | "long"; /** * Represents the system zone for this JavaScript environment. */ declare class SystemZone extends Zone { /** * Get a singleton instance of the system zone */ static get instance(): SystemZone; } declare interface ToHumanDurationOptions extends Intl.NumberFormatOptions { /** * How to format the merged list. * Corresponds to the `style` property of the options parameter of the native `Intl.ListFormat` constructor. * @default 'narrow' */ listStyle?: "long" | "short" | "narrow" | undefined; /** * Show all units previously used by the duration even if they are zero. * @default true */ showZeros?: boolean | undefined; } declare interface ToISODateOptions extends Pick { /** * Truncate output to desired presicion. * @default 'day' */ precision?: "year" | "years" | "month" | "months" | "day" | "days" | undefined; } declare type ToISOFormat = "basic" | "extended"; declare interface ToISOTimeDurationOptions { /** * Include the `T` prefix * @default false */ includePrefix?: boolean | undefined; /** * Exclude milliseconds from the format if they are 0 * @default false */ suppressMilliseconds?: boolean | undefined; /** * Exclude seconds from the format if they are 0 * @default false */ suppressSeconds?: boolean | undefined; /** * Choose between the basic and extended format * @default 'extended' */ format?: ToISOFormat | undefined; } declare interface ToISOTimeOptions extends ToISOTimeDurationOptions { /** * Include the offset, such as 'Z' or '-04:00' * @default true */ includeOffset?: boolean | undefined; /** * add the time zone format extension * @default false */ extendedZone?: boolean | undefined; /** * Truncate output to desired presicion. * When precision and suppressSeconds or suppressMilliseconds are used together, * precision sets the maximum unit shown in the output, * however seconds or milliseconds will still be suppressed if they are 0. * @default 'milliseconds' */ precision?: | "year" | "years" | "month" | "months" | "day" | "days" | "hour" | "hours" | "minute" | "minutes" | "second" | "seconds" | "millisecond" | "milliseconds"; } declare interface TokenParser { [tokenParserBrand]: true; } declare const tokenParserBrand: unique symbol; /** * # Table of tokens * * (The example values below come from this time `2014-08-06T13:07:04.054` * considered as a local time in America/New_York). * * Note that many tokens supported by the formatter are **not** supported by the parser. * * | Standalone token | Format token | Description | Example | * | ---------------- | ------------ | ----------------------------------------------------------------- | --------------------------- | * | S | | millisecond, no padding | `54` | * | SSS | | millisecond, padded to 3 | `054` | * | u | | fractional seconds, (5 is a half second, 54 is slightly more) | `54` | * | uu | | fractional seconds, (one or two digits) | `05` | * | uuu | | fractional seconds, (only one digit) | `5` | * | s | | second, no padding | `4` | * | ss | | second, padded to 2 padding | `04` | * | m | | minute, no padding | `7` | * | mm | | minute, padded to 2 | `07` | * | h | | hour in 12-hour time, no padding | `1` | * | hh | | hour in 12-hour time, padded to 2 | `01` | * | H | | hour in 24-hour time, no padding | `13` | * | HH | | hour in 24-hour time, padded to 2 | `13` | * | Z | | narrow offset | `+5` | * | ZZ | | short offset | `+05:00` | * | ZZZ | | techie offset | `+0500` | * | z | | IANA zone | `America/New_York` | * | a | | meridiem | `AM` | * | d | | day of the month, no padding | `6` | * | dd | | day of the month, padded to 2 | `06` | * | E | c | day of the week, as number from 1-7 (Monday is 1, Sunday is 7) | `3` | * | EEE | ccc | day of the week, as an abbreviate localized string | `Wed` | * | EEEE | cccc | day of the week, as an unabbreviated localized string | `Wednesday` | * | M | L | month as an unpadded number | `8` | * | MM | LL | month as an padded number | `08` | * | MMM | LLL | month as an abbreviated localized string | `Aug` | * | MMMM | LLLL | month as an unabbreviated localized string | `August` | * | y | | year, 1-6 digits, very literally | `2014` | * | yy | | two-digit year, interpreted as > 1960 by default (also accepts 4) | `14` | * | yyyy | | four-digit year | `2014` | * | yyyyy | | four- to six-digit years | `10340` | * | yyyyyy | | six-digit years | `010340` | * | G | | abbreviated localized era | `AD` | * | GG | | unabbreviated localized era | `Anno Domini` | * | GGGGG | | one-letter localized era | `A` | * | kk | | ISO week year, unpadded | `17` | * | kkkk | | ISO week year, padded to 4 | `2014` | * | W | | ISO week number, unpadded | `32` | * | WW | | ISO week number, padded to 2 | `32` | * | o | | ordinal (day of year), unpadded | `218` | * | ooo | | ordinal (day of year), padded to 3 | `218` | * | q | | quarter, no padding | `3` | * | D | | localized numeric date | `9/6/2014` | * | DD | | localized date with abbreviated month | `Aug 6, 2014` | * | DDD | | localized date with full month | `August 6, 2014` | * | DDDD | | localized date with full month and weekday | `Wednesday, August 6, 2014` | * | t | | localized time | `1:07 AM` | * | tt | | localized time with seconds | `1:07:04 PM` | * | T | | localized 24-hour time | `13:07` | * | TT | | localized 24-hour time with seconds | `13:07:04` | * | f | | short localized date and time | `8/6/2014, 1:07 PM` | * | ff | | less short localized date and time | `Aug 6, 2014, 1:07 PM` | * | F | | short localized date and time with seconds | `8/6/2014, 1:07:04 PM` | * | FF | | less short localized date and time with seconds | `Aug 6, 2014, 1:07:04 PM` | * | ' | | literal start/end, characters between are not tokenized | `'T'` | * * Sourced from [here](https://moment.github.io/luxon/#/parsing?id=table-of-tokens). */ declare type Tokens = string; declare type ToObjectOutput< IncludeConfig extends boolean | undefined = undefined, IsValid extends boolean | undefined = undefined, > = IsValid extends true ? _ToObjectOutput : CanBeInvalid extends false ? _ToObjectOutput : Partial<_ToObjectOutput>; export type _ToObjectOutput = & Record<_ToObjectUnit, number> & (IncludeConfig extends true ? LocaleOptions : unknown); export type _ToObjectUnit = Exclude; declare interface ToRelativeCalendarOptions { /** * The DateTime to use as the basis to which this time is compared * @default now */ base?: DateTime | undefined; /** * Override the locale of this DateTime */ locale?: string | undefined; /** If omitted, the method will pick the unit. */ unit?: ToRelativeUnit | undefined; /** * Override the numberingSystem of this DateTime. * The Intl system may choose not to honor this. */ numberingSystem?: NumberingSystem | undefined; } declare interface ToRelativeOptions extends Omit { /** * The style of units, must be "long", "short", or "narrow". * @default long */ style?: StringUnitLength | undefined; /** * A single unit or an array of units. If an array is supplied, the method will pick the best one * to use from the array. If omitted, the method will pick the unit from a default set. */ unit?: ToRelativeUnit | ToRelativeUnit[] | undefined; /** * Whether or not to round the numbers in the output. * @default true */ round?: boolean | undefined; /** * Rounding method to use when rounding the numbers in the output * @default 'trunc' */ rounding?: "trunc" | "expand" | "round" | "floor" | "ceil" | undefined; /** * Padding in milliseconds. This allows you to round up the result if it fits inside the threshold. * Do not use this in combination with `{round: false}` because the decimal output will include the padding. * @default 0 */ padding?: number | undefined; } declare type ToRelativeUnit = "years" | "quarters" | "months" | "weeks" | "days" | "hours" | "minutes" | "seconds"; declare interface ToSQLOptions { /** * Include the offset, such as 'Z' or '-04:00' * @default true */ includeOffset?: boolean | undefined; /** * Include the zone, such as 'America/New_York'. Overrides includeOffset. * @default false */ includeZone?: boolean | undefined; /** * include the space between the time and the offset, such as '05:15:16.345 -04:00' * @default true */ includeOffsetSpace?: boolean; } /** * TS only settings. Consumers can declaration merge this interface to change TS options. * * @see Settings.throwOnInvalid */ // eslint-disable-next-line @typescript-eslint/no-empty-interface declare interface TSSettings {} declare interface _UseLocaleWeekOption { /** If true, use weeks based on the locale, i.e., use the locale-dependent start of the week */ useLocaleWeeks?: boolean; } declare type Valid = true; declare type WeekdayNumbers = 1 | 2 | 3 | 4 | 5 | 6 | 7; declare type WeekNumbers = | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53; declare interface WeekSettings { firstDay: WeekdayNumbers; minimalDays: WeekdayNumbers; weekend: WeekdayNumbers[]; } declare abstract class Zone { /** * The type of zone */ get type(): IfValid; /** * The name of this zone. */ get name(): string; /** * Returns whether the offset is known to be fixed for the whole year. */ get isUniversal(): IfValid; /** * Returns the offset's common name (such as EST) at the specified timestamp * * @param ts - Epoch milliseconds for which to get the name * @param options - Options to affect the format * @param options.format - What style of offset to return. * @param options.locale - What locale to return the offset name in. */ offsetName(ts: number, options: ZoneOffsetOptions): IfValid; /** * Returns the offset's value as a string * * @param ts - Epoch milliseconds for which to get the offset * @param format - What style of offset to return. * Accepts 'narrow', 'short', or 'techie'. Returning '+6', '+06:00', or '+0600' respectively */ formatOffset(ts: number, format: ZoneOffsetFormat): IfValid; /** * Return the offset in minutes for this zone at the specified timestamp. * * @param ts - Epoch milliseconds for which to compute the offset */ offset(ts: number): IfValid; /** * Return whether this Zone is equal to another zone * * @param other - the zone to compare */ equals(other: Zone): IfValid; /** * Return whether this Zone is valid. */ get isValid(): IfValid; } /** * What style of offset to return. * Returning '+6', '+06:00', or '+0600' respectively */ declare type ZoneOffsetFormat = "narrow" | "short" | "techie"; declare interface ZoneOffsetOptions { /** * What style of offset to return. */ format?: "short" | "long" | undefined; /** * What locale to return the offset name in. */ locale?: string | undefined; } declare interface ZoneOptions { /** * 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. */ keepLocalTime?: boolean | undefined; /** * @deprecated since 0.2.12. Use keepLocalTime instead */ keepCalendarTime?: boolean | undefined; } export { }