@types/luxon

  • Version 1.26.5
  • Published
  • 86.6 kB
  • No dependencies
  • MIT license

Install

npm i @types/luxon
yarn add @types/luxon
pnpm add @types/luxon

Overview

TypeScript definitions for luxon

Index

Variables

Classes

Interfaces

Type Aliases

Namespaces

Variables

variable VERSION

const VERSION: string;

    Classes

    class DateTime

    class DateTime {}
    • 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 comprises of: * 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 effect 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: local, utc, and (most flexibly) fromObject. To create one from a standard string format, use fromISO, fromHTTP, and fromRFC2822. To create one from a custom string format, use fromFormat. To create one from a native JS date, use fromJSDate. * **Gregorian calendar and time**: To examine the Gregorian properties of a DateTime individually (i.e as opposed to collectively through toObject), use the year, month, day, hour, minute, second, millisecond accessors. * **Week calendar**: For ISO week calendar attributes, see the weekYear, weekNumber, and weekday accessors. * **Configuration** See the locale and numberingSystem accessors. * **Transformation**: To transform the DateTime into other DateTimes, use set, reconfigure, setZone, setLocale, plus, minus, endOf, startOf, toUTC, and toLocal. * **Output**: To convert the DateTime to other representations, use the toRelative, toRelativeCalendar, toJSON, toISO, toHTTP, toObject, toRFC2822, toString, toLocaleString, toFormat, toMillis and 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.

    property DATE_FULL

    static readonly DATE_FULL: Intl.DateTimeFormatOptions;

    property DATE_HUGE

    static readonly DATE_HUGE: Intl.DateTimeFormatOptions;

    property DATE_MED

    static readonly DATE_MED: Intl.DateTimeFormatOptions;

    property DATE_MED_WITH_WEEKDAY

    static readonly DATE_MED_WITH_WEEKDAY: Intl.DateTimeFormatOptions;

    property DATE_SHORT

    static readonly DATE_SHORT: Intl.DateTimeFormatOptions;

    property DATETIME_FULL

    static readonly DATETIME_FULL: Intl.DateTimeFormatOptions;
    • toLocaleString format like 'October 14, 1983, 9:30 AM EDT'. Only 12-hour if the locale is.

    property DATETIME_FULL_WITH_SECONDS

    static readonly DATETIME_FULL_WITH_SECONDS: Intl.DateTimeFormatOptions;
    • toLocaleString format like 'October 14, 1983, 9:30:33 AM EDT'. Only 12-hour if the locale is.

    property DATETIME_HUGE

    static readonly DATETIME_HUGE: Intl.DateTimeFormatOptions;
    • toLocaleString format like 'Friday, October 14, 1983, 9:30 AM Eastern Daylight Time'. Only 12-hour if the locale is.

    property DATETIME_HUGE_WITH_SECONDS

    static readonly DATETIME_HUGE_WITH_SECONDS: Intl.DateTimeFormatOptions;
    • toLocaleString format like 'Friday, October 14, 1983, 9:30:33 AM Eastern Daylight Time'. Only 12-hour if the locale is.

    property DATETIME_MED

    static readonly DATETIME_MED: Intl.DateTimeFormatOptions;
    • toLocaleString format like 'Oct 14, 1983, 9:30 AM'. Only 12-hour if the locale is.

    property DATETIME_MED_WITH_SECONDS

    static readonly DATETIME_MED_WITH_SECONDS: Intl.DateTimeFormatOptions;
    • toLocaleString format like 'Oct 14, 1983, 9:30:33 AM'. Only 12-hour if the locale is.

    property DATETIME_MED_WITH_WEEKDAY

    static readonly DATETIME_MED_WITH_WEEKDAY: Intl.DateTimeFormatOptions;
    • toLocaleString format like 'Fri, 14 Oct 1983, 9:30 AM'. Only 12-hour if the locale is.

    property DATETIME_SHORT

    static readonly DATETIME_SHORT: Intl.DateTimeFormatOptions;
    • toLocaleString format like '10/14/1983, 9:30 AM'. Only 12-hour if the locale is.

    property DATETIME_SHORT_WITH_SECONDS

    static readonly DATETIME_SHORT_WITH_SECONDS: Intl.DateTimeFormatOptions;
    • toLocaleString format like '10/14/1983, 9:30:33 AM'. Only 12-hour if the locale is.

    property day

    day: number;
    • Get the day of the month (1-30ish).

      Example 1

      DateTime.local(2017, 5, 25).day //=> 25

    property daysInMonth

    daysInMonth: number;
    • Returns the number of days in this DateTime's month

      Example 1

      DateTime.local(2016, 2).daysInMonth //=> 29

      Example 2

      DateTime.local(2016, 3).daysInMonth //=> 31

    property daysInYear

    daysInYear: number;
    • Returns the number of days in this DateTime's year

      Example 1

      DateTime.local(2016).daysInYear //=> 366

      Example 2

      DateTime.local(2013).daysInYear //=> 365

    property hour

    hour: number;
    • Get the hour of the day (0-23).

      Example 1

      DateTime.local(2017, 5, 25, 9).hour //=> 9

    property invalidExplanation

    invalidExplanation: string;
    • Returns an explanation of why this DateTime became invalid, or null if the DateTime is valid

    property invalidReason

    invalidReason: string;
    • Returns an error code if this DateTime is invalid, or null if the DateTime is valid

    property isInDST

    isInDST: boolean;
    • Get whether the DateTime is in a DST.

    property isInLeapYear

    isInLeapYear: boolean;
    • Returns true if this DateTime is in a leap year, false otherwise

      Example 1

      DateTime.local(2016).isInLeapYear //=> true

      Example 2

      DateTime.local(2013).isInLeapYear //=> false

    property isOffsetFixed

    isOffsetFixed: boolean;
    • Get whether this zone's offset ever changes, as in a DST.

    property isValid

    isValid: boolean;
    • 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

    property locale

    locale: string;
    • Get the locale of a DateTime, such 'en-GB'. The locale is used when formatting the DateTime

    property millisecond

    millisecond: number;
    • Get the millisecond of the second (0-999).

      Example 1

      DateTime.local(2017, 5, 25, 9, 30, 52, 654).millisecond //=> 654

    property minute

    minute: number;
    • Get the minute of the hour (0-59).

      Example 1

      DateTime.local(2017, 5, 25, 9, 30).minute //=> 30

    property month

    month: number;
    • Get the month (1-12).

      Example 1

      DateTime.local(2017, 5, 25).month //=> 5

    property monthLong

    monthLong: string;
    • Get the human readable long month name, such as 'October'. Defaults to the system's locale if no locale has been specified

      Example 1

      DateTime.local(2017, 10, 30).monthLong //=> October

    property monthShort

    monthShort: string;
    • Get the human readable short month name, such as 'Oct'. Defaults to the system's locale if no locale has been specified

      Example 1

      DateTime.local(2017, 10, 30).monthShort //=> Oct

    property numberingSystem

    numberingSystem: string;
    • Get the numbering system of a DateTime, such 'beng'. The numbering system is used when formatting the DateTime

    property offset

    offset: number;
    • Get the UTC offset of this DateTime in minutes

      Example 1

      DateTime.now().offset //=> -240

      Example 2

      DateTime.utc().offset //=> 0

    property offsetNameLong

    offsetNameLong: string;
    • 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

    property offsetNameShort

    offsetNameShort: string;
    • 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

    property ordinal

    ordinal: number;
    • Get the ordinal (meaning the day of the year)

      Example 1

      DateTime.local(2017, 5, 25).ordinal //=> 145

    property outputCalendar

    outputCalendar: string;
    • Get the output calendar of a DateTime, such 'islamic'. The output calendar is used when formatting the DateTime

    property quarter

    quarter: number;
    • Get the quarter

      Example 1

      DateTime.local(2017, 5, 25).quarter //=> 2

    property second

    second: number;
    • Get the second of the minute (0-59).

      Example 1

      DateTime.local(2017, 5, 25, 9, 30, 52).second //=> 52

    property TIME_24_SIMPLE

    static readonly TIME_24_SIMPLE: Intl.DateTimeFormatOptions;

    property TIME_24_WITH_LONG_OFFSET

    static readonly TIME_24_WITH_LONG_OFFSET: Intl.DateTimeFormatOptions;
    • toLocaleString format like '09:30:23 Eastern Daylight Time', always 24-hour.

    property TIME_24_WITH_SECONDS

    static readonly TIME_24_WITH_SECONDS: Intl.DateTimeFormatOptions;

    property TIME_24_WITH_SHORT_OFFSET

    static readonly TIME_24_WITH_SHORT_OFFSET: Intl.DateTimeFormatOptions;

    property TIME_SIMPLE

    static readonly TIME_SIMPLE: Intl.DateTimeFormatOptions;

    property TIME_WITH_LONG_OFFSET

    static readonly TIME_WITH_LONG_OFFSET: Intl.DateTimeFormatOptions;
    • toLocaleString format like '09:30:23 AM Eastern Daylight Time'. Only 12-hour if the locale is.

    property TIME_WITH_SECONDS

    static readonly TIME_WITH_SECONDS: Intl.DateTimeFormatOptions;
    • toLocaleString format like '09:30:23 AM'. Only 12-hour if the locale is.

    property TIME_WITH_SHORT_OFFSET

    static readonly TIME_WITH_SHORT_OFFSET: Intl.DateTimeFormatOptions;
    • toLocaleString format like '09:30:23 AM EDT'. Only 12-hour if the locale is.

    property weekday

    weekday: number;
    • Get the day of the week. 1 is Monday and 7 is Sunday

      Example 1

      DateTime.local(2014, 11, 31).weekday //=> 4

      See Also

      • https://en.wikipedia.org/wiki/ISO_week_date

    property weekdayLong

    weekdayLong: string;
    • Get the human readable long weekday, such as 'Monday'. Defaults to the system's locale if no locale has been specified

      Example 1

      DateTime.local(2017, 10, 30).weekdayLong //=> Monday

    property weekdayShort

    weekdayShort: string;
    • Get the human readable short weekday, such as 'Mon'. Defaults to the system's locale if no locale has been specified

      Example 1

      DateTime.local(2017, 10, 30).weekdayShort //=> Mon

    property weekNumber

    weekNumber: number;
    • Get the week number of the week year (1-52ish).

      Example 1

      DateTime.local(2017, 5, 25).weekNumber //=> 21

      See Also

      • https://en.wikipedia.org/wiki/ISO_week_date

    property weeksInWeekYear

    weeksInWeekYear: number;
    • Returns the number of weeks in this DateTime's year

      Example 1

      DateTime.local(2004).weeksInWeekYear //=> 53

      Example 2

      DateTime.local(2013).weeksInWeekYear //=> 52

      See Also

      • https://en.wikipedia.org/wiki/ISO_week_date

    property weekYear

    weekYear: number;
    • Get the week year

      Example 1

      DateTime.local(2014, 11, 31).weekYear //=> 2015

      See Also

      • https://en.wikipedia.org/wiki/ISO_week_date

    property year

    year: number;
    • Get the year

      Example 1

      DateTime.local(2017, 5, 25).year //=> 2017

    property zone

    zone: Zone;
    • Get the time zone associated with this DateTime.

    property zoneName

    zoneName: string;
    • Get the name of the time zone.

    method diff

    diff: (other: DateTime, unit?: DurationUnits, options?: DiffOptions) => Duration;
    • Return the difference between two DateTimes as a Duration.

      Parameter other

      the DateTime to compare this one to

      Parameter unit

      the unit or array of units (such as 'hours' or 'days') to include in the duration.

      Parameter options

      options that affect the creation of the Duration

      Parameter

      [options.conversionAccuracy='casual'] - the conversion system to use

      Example 1

      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 }

    method diffNow

    diffNow: (unit?: DurationUnits, options?: DiffOptions) => Duration;
    • Return the difference between this DateTime and right now. See diff

      Parameter unit

      the unit or units units (such as 'hours' or 'days') to include in the duration

      Parameter options

      options that affect the creation of the Duration

      Parameter

      [options.conversionAccuracy='casual'] - the conversion system to use

    method endOf

    endOf: (unit: DurationUnit) => DateTime;
    • "Set" this DateTime to the end (meaning the last millisecond) of a unit of time

      Example 1

      DateTime.local(2014, 3, 3).endOf('month').toISO(); //=> '2014-03-31T23:59:59.999-05:00'

      Example 2

      DateTime.local(2014, 3, 3).endOf('year').toISO(); //=> '2014-12-31T23:59:59.999-05:00'

      Example 3

      DateTime.local(2014, 3, 3).endOf('week').toISO(); // => '2014-03-09T23:59:59.999-05:00', weeks start on Mondays

      Example 4

      DateTime.local(2014, 3, 3, 5, 30).endOf('day').toISO(); //=> '2014-03-03T23:59:59.999-05:00'

      Example 5

      DateTime.local(2014, 3, 3, 5, 30).endOf('hour').toISO(); //=> '2014-03-03T05:59:59.999-05:00'

    method equals

    equals: (other: DateTime) => boolean;
    • Equality check Two DateTimes are equal 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.

    method fromFormat

    static fromFormat: (
    text: string,
    format: string,
    opts?: DateTimeOptions
    ) => DateTime;
    • 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.

      See Also

      • https://moment.github.io/luxon/docs/manual/parsing.html#table-of-tokens

    method fromFormatExplain

    static fromFormatExplain: (
    text: string,
    format: string,
    opts?: DateTimeOptions
    ) => ExplainedFormat;
    • Explain how a string would be parsed by fromFormat

    method fromHTTP

    static fromHTTP: (text: string, options?: DateTimeOptions) => DateTime;
    • Create a DateTime from an HTTP header date

      Parameter text

      the HTTP header date

      Parameter options

      options to affect the creation

      Parameter

      [options.zone='local'] - 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.

      Example 1

      DateTime.fromHTTP('Sun, 06 Nov 1994 08:49:37 GMT')

      Example 2

      DateTime.fromHTTP('Sunday, 06-Nov-94 08:49:37 GMT')

      Example 3

      DateTime.fromHTTP('Sun Nov 6 08:49:37 1994')

      See Also

      • https://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3.1

    method fromISO

    static fromISO: (text: string, options?: DateTimeOptions) => DateTime;
    • Create a DateTime from an ISO 8601 string

      Example 1

      DateTime.fromISO('2016-05-25T09:08:34.123')

      Example 2

      DateTime.fromISO('2016-05-25T09:08:34.123+06:00')

      Example 3

      DateTime.fromISO('2016-05-25T09:08:34.123+06:00', {setZone: true})

      Example 4

      DateTime.fromISO('2016-05-25T09:08:34.123', {zone: 'utc'})

      Example 5

      DateTime.fromISO('2016-W05-4')

    method fromJSDate

    static fromJSDate: (date: Date, options?: DateTimeJSOptions) => DateTime;
    • Create a DateTime from a JavaScript Date object. Uses the default zone.

    method fromMillis

    static fromMillis: (ms: number, options?: DateTimeOptions) => DateTime;
    • Create a DateTime from a number of milliseconds since the epoch (meaning since 1 January 1970 00:00:00 UTC). Uses the default zone.

    method fromObject

    static fromObject: (obj: DateObject) => DateTime;
    • Create a DateTime from a JavaScript object with keys like 'year' and 'hour' with reasonable defaults.

      Example 1

      DateTime.fromObject({ year: 1982, month: 5, day: 25}).toISODate() //=> '1982-05-25'

      Example 2

      DateTime.fromObject({ year: 1982 }).toISODate() //=> '1982-01-01'

      Example 3

      DateTime.fromObject({ hour: 10, minute: 26, second: 6 }) //~> today at 10:26:06

      Example 4

      DateTime.fromObject({ hour: 10, minute: 26, second: 6, zone: 'utc' }),

      Example 5

      DateTime.fromObject({ hour: 10, minute: 26, second: 6, zone: 'local' })

      Example 6

      DateTime.fromObject({ hour: 10, minute: 26, second: 6, zone: 'America/New_York' })

      Example 7

      DateTime.fromObject({ weekYear: 2016, weekNumber: 2, weekday: 3 }).toISODate() //=> '2016-01-13'

    method fromRFC2822

    static fromRFC2822: (text: string, options?: DateTimeOptions) => DateTime;
    • Create a DateTime from an RFC 2822 string

      Example 1

      DateTime.fromRFC2822('25 Nov 2016 13:23:12 GMT')

      Example 2

      DateTime.fromRFC2822('Fri, 25 Nov 2016 13:23:12 +0600')

      Example 3

      DateTime.fromRFC2822('25 Nov 2016 13:23 Z')

    method fromSeconds

    static fromSeconds: (seconds: number, options?: DateTimeOptions) => DateTime;
    • Create a DateTime from a number of seconds since the epoch (meaning since 1 January 1970 00:00:00 UTC). Uses the default zone.

    method fromSQL

    static fromSQL: (text: string, options?: DateTimeOptions) => DateTime;
    • 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

      Example 1

      DateTime.fromSQL('2017-05-15')

      Example 2

      DateTime.fromSQL('2017-05-15 09:12:34')

      Example 3

      DateTime.fromSQL('2017-05-15 09:12:34.342')

      Example 4

      DateTime.fromSQL('2017-05-15 09:12:34.342+06:00')

      Example 5

      DateTime.fromSQL('2017-05-15 09:12:34.342 America/Los_Angeles')

      Example 6

      DateTime.fromSQL('2017-05-15 09:12:34.342 America/Los_Angeles', { setZone: true })

      Example 7

      DateTime.fromSQL('2017-05-15 09:12:34.342', { zone: 'America/Los_Angeles' })

      Example 8

      DateTime.fromSQL('09:12:34.342')

    method fromString

    static fromString: (
    text: string,
    format: string,
    options?: DateTimeOptions
    ) => DateTime;

    method fromStringExplain

    static fromStringExplain: (
    text: string,
    format: string,
    options?: DateTimeOptions
    ) => ExplainedFormat;

    method get

    get: (unit: keyof DateTime) => number;
    • Get the value of unit.

      Example 1

      DateTime.local(2017, 7, 4).get('month'); //=> 7

      Example 2

      DateTime.local(2017, 7, 4).get('day'); //=> 4

    method hasSame

    hasSame: (other: DateTime, unit: DurationUnit) => boolean;
    • Return whether this DateTime is in the same unit of time as another DateTime. Higher-order units must also be identical for this function to return true. Note that time zones are **ignored** in this comparison, which compares the **local** calendar time. Use setZone to convert one of the dates if needed.

      Example 1

      DateTime.now().hasSame(otherDT, 'day'); //~> true if otherDT is in the same current calendar day

    method invalid

    static invalid: (reason: string, explanation?: string) => DateTime;
    • Create an invalid DateTime.

      Parameter reason

      simple string of why this DateTime is invalid. Should not contain parameters or anything else data-dependent

      Parameter explanation

      longer explanation, may include parameters and other useful debugging information

    method isDateTime

    static isDateTime: (o: any) => o is DateTime;
    • Check if an object is a DateTime. Works across context boundaries

    method local

    static local: (
    year?: number,
    month?: number,
    day?: number,
    hour?: number,
    minute?: number,
    second?: number,
    millisecond?: number
    ) => DateTime;
    • Create a local DateTime

      Parameter year

      The calendar year. If omitted (as in, call local() with no arguments), the current time will be used

      Parameter month

      The month, 1-indexed

      Parameter day

      The day of the month, 1-indexed

      Parameter hour

      The hour of the day, in 24-hour time

      Parameter minute

      The minute of the hour, meaning a number between 0 and 59

      Parameter second

      The second of the minute, meaning a number between 0 and 59

      Parameter millisecond

      The millisecond of the second, meaning a number between 0 and 999

      Example 1

      DateTime.local() //~> now

      Example 2

      DateTime.local(2017) //~> 2017-01-01T00:00:00

      Example 3

      DateTime.local(2017, 3) //~> 2017-03-01T00:00:00

      Example 4

      DateTime.local(2017, 3, 12) //~> 2017-03-12T00:00:00

      Example 5

      DateTime.local(2017, 3, 12, 5) //~> 2017-03-12T05:00:00

      Example 6

      DateTime.local(2017, 3, 12, 5, 45) //~> 2017-03-12T05:45:00

      Example 7

      DateTime.local(2017, 3, 12, 5, 45, 10) //~> 2017-03-12T05:45:10

      Example 8

      DateTime.local(2017, 3, 12, 5, 45, 10, 765) //~> 2017-03-12T05:45:10.765

    method max

    static max: { (): undefined; (...dateTimes: DateTime[]): DateTime };
    • Return the maximum of several date times

    method min

    static min: { (): undefined; (...dateTimes: DateTime[]): DateTime };
    • Return the minimum of several date times

    method minus

    minus: (duration: DurationInput) => DateTime;
    • Subtract a period of time to this DateTime and return the resulting DateTime See plus

    method now

    static now: () => DateTime;
    • Create a DateTime for the current instant, in the system's time zone.

      Use Settings to override these default values if needed.

      Example 1

      DateTime.now().toISO() //~> now in the ISO format

    method plus

    plus: (duration: DurationInput) => DateTime;
    • Add a period of time to this DateTime and return the resulting DateTime

      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.

      Example 1

      DateTime.now().plus(123) //~> in 123 milliseconds

      Example 2

      DateTime.now().plus({ minutes: 15 }) //~> in 15 minutes

      Example 3

      DateTime.now().plus({ days: 1 }) //~> this time tomorrow

      Example 4

      DateTime.now().plus({ days: -1 }) //~> this time yesterday

      Example 5

      DateTime.now().plus({ hours: 3, minutes: 13 }) //~> in 3 hr, 13 min

      Example 6

      DateTime.now().plus(Duration.fromObject({ hours: 3, minutes: 13 })) //~> in 3 hr, 13 min

    method reconfigure

    reconfigure: (properties: LocaleOptions) => DateTime;
    • "Set" the locale options. Returns a newly-constructed DateTime.

    method resolvedLocaleOpts

    resolvedLocaleOpts: (
    options?: LocaleOptions & DateTimeFormatOptions
    ) => Intl.ResolvedDateTimeFormatOptions;
    • Returns the resolved Intl options for this DateTime. This is useful in understanding the behavior of formatting methods

    method set

    set: (values: DateObjectUnits) => DateTime;
    • "Set" the values of specified units. Returns a newly-constructed DateTime. You can only set units with this method; for setting metadata, see reconfigure and setZone.

    method setLocale

    setLocale: (locale: string) => DateTime;
    • "Set" the locale. Returns a newly-constructed DateTime. Just a convenient alias for reconfigure({ locale })

    method setZone

    setZone: (zone: string | Zone, options?: ZoneOptions) => DateTime;
    • "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 plus. You may wish to use toLocal and toUTC which provide simple convenience wrappers for commonly used zones.

      Parameter 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 Zone class.

      Parameter options

      options

    method startOf

    startOf: (unit: DurationUnit) => DateTime;
    • "Set" this DateTime to the beginning of a unit of time.

      Example 1

      DateTime.local(2014, 3, 3).startOf('month').toISODate(); //=> '2014-03-01'

      Example 2

      DateTime.local(2014, 3, 3).startOf('year').toISODate(); //=> '2014-01-01'

      Example 3

      DateTime.local(2014, 3, 3).startOf('week').toISODate(); //=> '2014-03-03', weeks always start on Mondays

      Example 4

      DateTime.local(2014, 3, 3, 5, 30).startOf('day').toISOTime(); //=> '00:00.000-05:00'

      Example 5

      DateTime.local(2014, 3, 3, 5, 30).startOf('hour').toISOTime(); //=> '05:00:00.000-05:00'

    method toBSON

    toBSON: () => Date;
    • Returns a BSON serializable equivalent to this DateTime.

    method toFormat

    toFormat: (
    format: string,
    options?: LocaleOptions & DateTimeFormatOptions
    ) => string;
    • Returns a string representation of this DateTime formatted according to the specified format string.

      **You may not want this.** See toLocaleString for a more flexible formatting tool.

      For a table of tokens and their interpretations, see [here](https://moment.github.io/luxon/docs/manual/formatting.html#table-of-tokens).

      Defaults to en-US if no locale has been specified, regardless of the system's locale.

      Example 1

      DateTime.now().toFormat('yyyy LLL dd') //=> '2017 Apr 22'

      Example 2

      DateTime.now().setLocale('fr').toFormat('yyyy LLL dd') //=> '2017 avr. 22'

      Example 3

      DateTime.now().toFormat('yyyy LLL dd', { locale: "fr" }) //=> '2017 avr. 22'

      Example 4

      DateTime.now().toFormat("HH 'hours and' mm 'minutes'") //=> '20 hours and 55 minutes'

      See Also

      • https://moment.github.io/luxon/docs/manual/formatting.html#table-of-tokens

    method toHTTP

    toHTTP: () => string;
    • Returns a string representation of this DateTime appropriate for use in HTTP headers. Specifically, the string conforms to RFC 1123.

      Example 1

      DateTime.utc(2014, 7, 13).toHTTP() //=> 'Sun, 13 Jul 2014 00:00:00 GMT'

      Example 2

      DateTime.utc(2014, 7, 13, 19).toHTTP() //=> 'Sun, 13 Jul 2014 19:00:00 GMT'

      See Also

      • https://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3.1

    method toISO

    toISO: (options?: ToISOTimeOptions) => string;
    • Returns an ISO 8601-compliant string representation of this DateTime

      Example 1

      DateTime.utc(1982, 5, 25).toISO() //=> '1982-05-25T00:00:00.000Z'

      Example 2

      DateTime.now().toISO() //=> '2017-04-22T20:47:05.335-04:00'

      Example 3

      DateTime.now().toISO({ includeOffset: false }) //=> '2017-04-22T20:47:05.335'

      Example 4

      DateTime.now().toISO({ format: 'basic' }) //=> '20170422T204705.335-0400'

    method toISODate

    toISODate: (options?: ToISODateOptions) => string;
    • Returns an ISO 8601-compliant string representation of this DateTime's date component

      Example 1

      DateTime.utc(1982, 5, 25).toISODate() //=> '1982-05-25'

      Example 2

      DateTime.utc(1982, 5, 25).toISODate({ format: 'basic' }) //=> '19820525'

    method toISOTime

    toISOTime: (options?: ToISOTimeOptions) => string;
    • Returns an ISO 8601-compliant string representation of this DateTime's time component

      Example 1

      DateTime.utc().set({ hour: 7, minute: 34 }).toISOTime() //=> '07:34:19.361Z'

      Example 2

      DateTime.utc().set({ hour: 7, minute: 34, seconds: 0, milliseconds: 0 }).toISOTime({ suppressSeconds: true }) //=> '07:34Z'

      Example 3

      DateTime.utc().set({ hour: 7, minute: 34 }).toISOTime({ format: 'basic' }) //=> '073419.361Z'

      Example 4

      DateTime.utc().set({ hour: 7, minute: 34 }).toISOTime({ includePrefix: true }) //=> 'T07:34:19.361Z'

    method toISOWeekDate

    toISOWeekDate: () => string;
    • Returns an ISO 8601-compliant string representation of this DateTime's week date

      Example 1

      DateTime.utc(1982, 5, 25).toISOWeekDate() //=> '1982-W21-2'

    method toJSDate

    toJSDate: () => Date;
    • Returns a JavaScript Date equivalent to this DateTime.

    method toJSON

    toJSON: () => string;
    • Returns an ISO 8601 representation of this DateTime appropriate for use in JSON. Called implicitly via JSON.stringify

    method toLocal

    toLocal: () => DateTime;
    • "Set" the DateTime's zone to the host's local zone. Returns a newly-constructed DateTime.

      Equivalent to setZone('local')

    method toLocaleParts

    toLocaleParts: (options?: LocaleOptions & DateTimeFormatOptions) => any[];
    • 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

      Example 1

      DateTime.now().toLocaleParts(); //=> [ //=> { type: 'day', value: '25' }, //=> { type: 'literal', value: '/' }, //=> { type: 'month', value: '05' }, //=> { type: 'literal', value: '/' }, //=> { type: 'year', value: '1982' } //=> ]

      See Also

      • https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/formatToParts

    method toLocaleString

    toLocaleString: (options?: LocaleOptions & DateTimeFormatOptions) => string;
    • 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. The exact behavior of this method is browser-specific, but in general it will return an appropriate representation of the DateTime in the assigned locale. Defaults to the system's locale if no locale has been specified

      Example 1

      DateTime.now().toLocaleString(); //=> 4/20/2017

      Example 2

      DateTime.now().setLocale('en-gb').toLocaleString(); //=> '20/04/2017'

      Example 3

      DateTime.now().toLocaleString({ locale: 'en-gb' }); //=> '20/04/2017'

      Example 4

      DateTime.now().toLocaleString(DateTime.DATE_FULL); //=> 'April 20, 2017'

      Example 5

      DateTime.now().toLocaleString(DateTime.TIME_SIMPLE); //=> '11:32 AM'

      Example 6

      DateTime.now().toLocaleString(DateTime.DATETIME_SHORT); //=> '4/20/2017, 11:32 AM'

      Example 7

      DateTime.now().toLocaleString({ weekday: 'long', month: 'long', day: '2-digit' }); //=> 'Thursday, April 20'

      Example 8

      DateTime.now().toLocaleString({ weekday: 'short', month: 'short', day: '2-digit', hour: '2-digit', minute: '2-digit' }); //=> 'Thu, Apr 20, 11:27 AM'

      Example 9

      DateTime.now().toLocaleString({ hour: '2-digit', minute: '2-digit', hour12: false }); //=> '11:32'

      See Also

      • https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat

    method toMillis

    toMillis: () => number;
    • Returns the epoch milliseconds of this DateTime.

    method toObject

    toObject: (options?: { includeConfig?: boolean }) => DateObject;
    • Returns a JavaScript object with this DateTime's year, month, day, and so on.

      Example 1

      DateTime.now().toObject() //=> { year: 2017, month: 4, day: 22, hour: 20, minute: 49, second: 42, millisecond: 268 }

    method toRelative

    toRelative: (options?: ToRelativeOptions) => string | null;
    • Returns a string representation of a this time relative to now, such as "in two days". Can only internationalize if your platform supports Intl.RelativeTimeFormat. Rounds down by default.

      Example 1

      DateTime.now().plus({ days: 1 }).toRelative() //=> "in 1 day"

      Example 2

      DateTime.now().setLocale("es").toRelative({ days: 1 }) //=> "dentro de 1 día"

      Example 3

      DateTime.now().plus({ days: 1 }).toRelative({ locale: "fr" }) //=> "dans 23 heures"

      Example 4

      DateTime.now().minus({ days: 2 }).toRelative() //=> "2 days ago"

      Example 5

      DateTime.now().minus({ days: 2 }).toRelative({ unit: "hours" }) //=> "48 hours ago"

      Example 6

      DateTime.now().minus({ hours: 36 }).toRelative({ round: false }) //=> "1.5 days ago"

    method toRelativeCalendar

    toRelativeCalendar: (options?: ToRelativeCalendarOptions) => string | null;
    • Returns a string representation of this date relative to today, such as "yesterday" or "next month". Only internationalizes on platforms that supports Intl.RelativeTimeFormat.

      Example 1

      DateTime.now().plus({ days: 1 }).toRelativeCalendar() //=> "tomorrow"

      Example 2

      DateTime.now().setLocale("es").plus({ days: 1 }).toRelative() //=> "mañana"

      Example 3

      DateTime.now().plus({ days: 1 }).toRelativeCalendar({ locale: "fr" }) //=> "demain"

      Example 4

      DateTime.now().minus({ days: 2 }).toRelativeCalendar() //=> "2 days ago"

    method toRFC2822

    toRFC2822: () => string;
    • Returns an RFC 2822-compatible string representation of this DateTime, always in UTC

      Example 1

      DateTime.utc(2014, 7, 13).toRFC2822() //=> 'Sun, 13 Jul 2014 00:00:00 +0000'

      Example 2

      DateTime.local(2014, 7, 13).toRFC2822() //=> 'Sun, 13 Jul 2014 00:00:00 -0400'

    method toSeconds

    toSeconds: () => number;
    • Returns the epoch seconds of this DateTime.

    method toSQL

    toSQL: (options?: ToSQLOptions) => string;
    • Returns a string representation of this DateTime appropriate for use in SQL DateTime

      Example 1

      DateTime.utc(2014, 7, 13).toSQL() //=> '2014-07-13 00:00:00.000 Z'

      Example 2

      DateTime.local(2014, 7, 13).toSQL() //=> '2014-07-13 00:00:00.000 -04:00'

      Example 3

      DateTime.local(2014, 7, 13).toSQL({ includeOffset: false }) //=> '2014-07-13 00:00:00.000'

      Example 4

      DateTime.local(2014, 7, 13).toSQL({ includeZone: true }) //=> '2014-07-13 00:00:00.000 America/New_York'

    method toSQLDate

    toSQLDate: () => string;
    • Returns a string representation of this DateTime appropriate for use in SQL Date

      Example 1

      DateTime.utc(2014, 7, 13).toSQLDate() //=> '2014-07-13'

    method toSQLTime

    toSQLTime: (options?: ToSQLOptions) => string;
    • Returns a string representation of this DateTime appropriate for use in SQL Time

      Example 1

      DateTime.utc().toSQL() //=> '05:15:16.345'

      Example 2

      DateTime.now().toSQL() //=> '05:15:16.345 -04:00'

      Example 3

      DateTime.now().toSQL({ includeOffset: false }) //=> '05:15:16.345'

      Example 4

      DateTime.now().toSQL({ includeZone: false }) //=> '05:15:16.345 America/New_York'

    method toString

    toString: () => string;
    • Returns a string representation of this DateTime appropriate for debugging

    method toUTC

    toUTC: (offset?: number, options?: ZoneOptions) => DateTime;
    • "Set" the DateTime's zone to UTC. Returns a newly-constructed DateTime.

      Equivalent to setZone('utc')

      Parameter offset

      optionally, an offset from UTC in minutes

      Parameter options

      options to pass to setZone()

    method until

    until: (other: DateTime) => Interval;
    • Return an Interval spanning between this DateTime and another DateTime

    method utc

    static utc: (
    year?: number,
    month?: number,
    day?: number,
    hour?: number,
    minute?: number,
    second?: number,
    millisecond?: number
    ) => DateTime;
    • Create a DateTime in UTC

      Parameter year

      The calendar year. If omitted (as in, call utc() with no arguments), the current time will be used

      Parameter month

      The month, 1-indexed

      Parameter day

      The day of the month

      Parameter hour

      The hour of the day, in 24-hour time

      Parameter minute

      The minute of the hour, meaning a number between 0 and 59

      Parameter second

      The second of the minute, meaning a number between 0 and 59

      Parameter millisecond

      The millisecond of the second, meaning a number between 0 and 999

      Example 1

      DateTime.utc() //~> now

      Example 2

      DateTime.utc(2017) //~> 2017-01-01T00:00:00Z

      Example 3

      DateTime.utc(2017, 3) //~> 2017-03-01T00:00:00Z

      Example 4

      DateTime.utc(2017, 3, 12) //~> 2017-03-12T00:00:00Z

      Example 5

      DateTime.utc(2017, 3, 12, 5) //~> 2017-03-12T05:00:00Z

      Example 6

      DateTime.utc(2017, 3, 12, 5, 45) //~> 2017-03-12T05:45:00Z

      Example 7

      DateTime.utc(2017, 3, 12, 5, 45, 10) //~> 2017-03-12T05:45:10Z

      Example 8

      DateTime.utc(2017, 3, 12, 5, 45, 10, 765) //~> 2017-03-12T05:45:10.765Z

    method valueOf

    valueOf: () => number;
    • Returns the epoch milliseconds of this DateTime. Alias of toMillis Called implicitly when coercing types.

    class Duration

    class Duration {}

    property days

    days: number;

      property hours

      hours: number;

        property invalidExplanation

        invalidExplanation: string;
        • Returns an explanation of why this Duration became invalid, or null if the Duration is valid

        property invalidReason

        invalidReason: string;
        • Returns an error code if this Duration became invalid, or null if the Duration is valid

        property isValid

        isValid: boolean;
        • Returns whether the Duration is invalid. Invalid durations are returned by diff operations on invalid DateTimes or Intervals.

        property locale

        locale: string;
        • Get the locale of a Duration, such 'en-GB'

        property milliseconds

        milliseconds: number;

          property minutes

          minutes: number;

            property months

            months: number;

              property numberingSystem

              numberingSystem: string;
              • Get the numbering system of a Duration, such 'beng'. The numbering system is used when formatting the Duration

              property quarters

              quarters: number;

                property seconds

                seconds: number;

                  property weeks

                  weeks: number;

                    property years

                    years: number;

                      method as

                      as: (unit: DurationUnit) => number;
                      • Return the length of the duration in the specified unit.

                        Example 1

                        Duration.fromObject({years: 1}).as('days') //=> 365

                        Example 2

                        Duration.fromObject({years: 1}).as('months') //=> 12

                        Example 3

                        Duration.fromObject({hours: 60}).as('days') //=> 2.5

                      method equals

                      equals: (other: Duration) => boolean;
                      • Equality check Two Durations are equal if they have the same units and the same values for each unit.

                      method fromISO

                      static fromISO: (text: string, options?: DurationOptions) => Duration;
                      • Create a Duration from an ISO 8601 duration string.

                        Example 1

                        Duration.fromISO('P3Y6M1W4DT12H30M5S').toObject() //=> { years: 3, months: 6, weeks: 1, days: 4, hours: 12, minutes: 30, seconds: 5 }

                        Example 2

                        Duration.fromISO('PT23H').toObject() //=> { hours: 23 }

                        Example 3

                        Duration.fromISO('P5Y3M').toObject() //=> { years: 5, months: 3 }

                        See Also

                        • https://en.wikipedia.org/wiki/ISO_8601#Durations

                      method fromISOTime

                      static fromISOTime: (text: string, options?: DurationOptions) => Duration;
                      • Create a Duration from an ISO 8601 time string.

                        Example 1

                        Duration.fromISOTime('11:22:33.444').toObject() //=> { hours: 11, minutes: 22, seconds: 33, milliseconds: 444 }

                        Example 2

                        Duration.fromISOTime('11:00').toObject() //=> { hours: 11, minutes: 0, seconds: 0 }

                        Example 3

                        Duration.fromISOTime('T11:00').toObject() //=> { hours: 11, minutes: 0, seconds: 0 }

                        Example 4

                        Duration.fromISOTime('1100').toObject() //=> { hours: 11, minutes: 0, seconds: 0 }

                        Example 5

                        Duration.fromISOTime('T1100').toObject() //=> { hours: 11, minutes: 0, seconds: 0 }

                        See Also

                        • https://en.wikipedia.org/wiki/ISO_8601#Times

                      method fromMillis

                      static fromMillis: (count: number, options?: DurationOptions) => Duration;
                      • Create Duration from a number of milliseconds.

                        Parameter count

                        of milliseconds

                        Parameter options

                        options for parsing

                        Parameter

                        [options.locale='en-US'] - the locale to use

                        Parameter

                        [options.numberingSystem] - the numbering system to use

                        Parameter

                        [options.conversionAccuracy='casual'] - the conversion system to use

                      method fromObject

                      static fromObject: (obj: DurationObject) => 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.

                      method get

                      get: (unit: DurationUnit) => number;
                      • Get the value of unit.

                        Example 1

                        Duration.fromObject({years: 2, days: 3}).years //=> 2

                        Example 2

                        Duration.fromObject({years: 2, days: 3}).months //=> 0

                        Example 3

                        Duration.fromObject({years: 2, days: 3}).days //=> 3

                      method invalid

                      static invalid: (reason: string, explanation?: string) => Duration;
                      • Create an invalid Duration.

                        Parameter reason

                        simple string of why this datetime is invalid. Should not contain parameters or anything else data-dependent

                        Parameter explanation

                        longer explanation, may include parameters and other useful debugging information

                      method isDuration

                      static isDuration: (o: any) => o is Duration;
                      • Check if an object is a Duration. Works across context boundaries

                      method mapUnits

                      mapUnits: (fn: (x: number, u: DurationUnit) => number) => Duration;
                      • Scale this Duration by the specified amount. Return a newly-constructed Duration.

                        Example 1

                        Duration.fromObject({ hours: 1, minutes: 30 }).mapUnit(x => x * 2) //=> { hours: 2, minutes: 60 }

                        Example 2

                        Duration.fromObject({ hours: 1, minutes: 30 }).mapUnit((x, u) => u === "hour" ? x * 2 : x) //=> { hours: 2, minutes: 30 }

                      method minus

                      minus: (duration: DurationInput) => Duration;
                      • Make this Duration shorter by the specified amount. Return a newly-constructed Duration.

                      method negate

                      negate: () => Duration;
                      • Return the negative of this Duration.

                        Example 1

                        Duration.fromObject({ hours: 1, seconds: 30 }).negate().toObject() //=> { hours: -1, seconds: -30 }

                      method normalize

                      normalize: () => Duration;
                      • Reduce this Duration to its canonical representation in its current units.

                        Example 1

                        Duration.fromObject({ years: 2, days: 5000 }).normalize().toObject() //=> { years: 15, days: 255 }

                        Example 2

                        Duration.fromObject({ hours: 12, minutes: -45 }).normalize().toObject() //=> { hours: 11, minutes: 15 }

                      method plus

                      plus: (duration: DurationInput) => Duration;
                      • Make this Duration longer by the specified amount. Return a newly-constructed Duration.

                      method reconfigure

                      reconfigure: (options: DurationOptions) => Duration;
                      • "Set" the Duration's options. Returns a newly-constructed Duration.

                      method set

                      set: (values: DurationObjectUnits) => Duration;
                      • "Set" the values of specified units. Return a newly-constructed Duration.

                      method shiftTo

                      shiftTo: (...units: DurationUnit[]) => Duration;
                      • Convert this Duration into its representation in a different set of units.

                        Example 1

                        Duration.fromObject({ hours: 1, seconds: 30 }).shiftTo('minutes', 'milliseconds').toObject() //=> { minutes: 60, milliseconds: 30000 }

                      method toFormat

                      toFormat: (format: string, options?: DurationToFormatOptions) => string;
                      • 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 Duration.shiftTo and the Duration's conversion accuracy setting.

                        Parameter format

                        the format string

                        Parameter options

                        options

                        Parameter

                        [options.floor=true] - floor numerical values

                        Example 1

                        Duration.fromObject({ years: 1, days: 6, seconds: 2 }).toFormat("y d s") //=> "1 6 2"

                        Example 2

                        Duration.fromObject({ years: 1, days: 6, seconds: 2 }).toFormat("yy dd sss") //=> "01 06 002"

                        Example 3

                        Duration.fromObject({ years: 1, days: 6, seconds: 2 }).toFormat("M S") //=> "12 518402000"

                      method toISO

                      toISO: () => string;
                      • Returns an ISO 8601-compliant string representation of this Duration.

                        Example 1

                        Duration.fromObject({ years: 3, seconds: 45 }).toISO() //=> 'P3YT45S'

                        Example 2

                        Duration.fromObject({ months: 4, seconds: 45 }).toISO() //=> 'P4MT45S'

                        Example 3

                        Duration.fromObject({ months: 5 }).toISO() //=> 'P5M'

                        Example 4

                        Duration.fromObject({ minutes: 5 }).toISO() //=> 'PT5M'

                        Example 5

                        Duration.fromObject({ milliseconds: 6 }).toISO() //=> 'PT0.006S'

                        See Also

                        • https://en.wikipedia.org/wiki/ISO_8601#Durations

                      method toISOTime

                      toISOTime: (options?: ToISOTimeDurationOptions) => string;
                      • Returns an ISO 8601-compliant string representation of this Duration, formatted as a time of day. Note that this will return null if the duration is invalid, negative, or equal to or greater than 24 hours.

                        Example 1

                        Duration.fromObject({ hours: 11 }).toISOTime() //=> '11:00:00.000'

                        Example 2

                        Duration.fromObject({ hours: 11 }).toISOTime({ suppressMilliseconds: true }) //=> '11:00:00'

                        Example 3

                        Duration.fromObject({ hours: 11 }).toISOTime({ suppressSeconds: true }) //=> '11:00'

                        Example 4

                        Duration.fromObject({ hours: 11 }).toISOTime({ includePrefix: true }) //=> 'T11:00:00.000'

                        Example 5

                        Duration.fromObject({ hours: 11 }).toISOTime({ format: 'basic' }) //=> '110000.000'

                        See Also

                        • https://en.wikipedia.org/wiki/ISO_8601#Times

                      method toJSON

                      toJSON: () => string;
                      • Returns an ISO 8601 representation of this Duration appropriate for use in JSON. Called implicitly via JSON.stringify

                      method toMillis

                      toMillis: () => number;
                      • Returns a milliseconds value of this Duration.

                      method toObject

                      toObject: (options?: { includeConfig?: boolean }) => DurationObject;
                      • Returns a JavaScript object with this Duration's values.

                        Parameter options

                        options for generating the object

                        Parameter

                        [options.includeConfig=false] - include configuration attributes in the output

                        Example 1

                        Duration.fromObject({ years: 1, days: 6, seconds: 2 }).toObject() //=> { years: 1, days: 6, seconds: 2 }

                      method toString

                      toString: () => string;
                      • Returns an ISO 8601 representation of this Duration appropriate for use in debugging.

                      method valueOf

                      valueOf: () => number;
                      • Returns an milliseconds value of this Duration. Alias of toMillis Called implicitly when coercing types.

                      class FixedOffsetZone

                      class FixedOffsetZone extends Zone {}
                      • A zone with a fixed offset (meaning no DST)

                      property utcInstance

                      static utcInstance: FixedOffsetZone;
                      • Get a singleton instance of UTC

                      method instance

                      static instance: (offset: number) => FixedOffsetZone;
                      • Get an instance with a specified offset

                        Parameter offset

                        The offset in minutes

                      method parseSpecifier

                      static parseSpecifier: (s: string) => FixedOffsetZone;
                      • Get an instance of FixedOffsetZone from a UTC offset string, like "UTC+6"

                        Parameter s

                        The offset string to parse

                        Example 1

                        FixedOffsetZone.parseSpecifier("UTC+6")

                        Example 2

                        FixedOffsetZone.parseSpecifier("UTC+06")

                        Example 3

                        FixedOffsetZone.parseSpecifier("UTC-6:00")

                      class IANAZone

                      class IANAZone extends Zone {}
                      • A zone identified by an IANA identifier, like America/New_York

                      constructor

                      constructor(ianaString: string);

                        method create

                        static create: (ianaString: string) => IANAZone;
                        • Same as constructor but has caching.

                        method isValidSpecifier

                        static isValidSpecifier: (s: string) => boolean;
                        • Returns whether the provided string is a valid specifier. This only checks the string's format, not that the specifier identifies a known zone; see isValidZone for that.

                          Parameter s

                          The string to check validity on

                          Example 1

                          IANAZone.isValidSpecifier("America/New_York") //=> true

                          Example 2

                          IANAZone.isValidSpecifier("Fantasia/Castle") //=> true

                          Example 3

                          IANAZone.isValidSpecifier("Sport~~blorp") //=> false

                        method isValidZone

                        static isValidZone: (zone: string) => boolean;
                        • Returns whether the provided string identifies a real zone

                          Parameter zone

                          The string to check

                          Example 1

                          IANAZone.isValidZone("America/New_York") //=> true

                          Example 2

                          IANAZone.isValidZone("Fantasia/Castle") //=> false

                          Example 3

                          IANAZone.isValidZone("Sport~~blorp") //=> false

                        method resetCache

                        static resetCache: () => void;
                        • Reset local caches. Should only be necessary in testing scenarios.

                        class Interval

                        class Interval {}

                        property end

                        end: DateTime;
                        • Returns the end of the Interval

                        property invalidExplanation

                        invalidExplanation: string;
                        • Returns an explanation of why this Interval became invalid, or null if the Interval is valid

                        property invalidReason

                        invalidReason: string;
                        • Returns an error code if this Interval is invalid, or null if the Interval is valid

                        property isValid

                        isValid: boolean;
                        • Returns whether this Interval's end is at least its start, meaning that the Interval isn't 'backwards'.

                        property start

                        start: DateTime;
                        • Returns the start of the Interval

                        method abutsEnd

                        abutsEnd: (other: Interval) => boolean;
                        • Return whether this Interval's start is adjacent to the specified Interval's end.

                        method abutsStart

                        abutsStart: (other: Interval) => boolean;
                        • Return whether this Interval's end is adjacent to the specified Interval's start.

                        method after

                        static after: (start: DateInput, duration: DurationInput) => Interval;
                        • Create an Interval from a start DateTime and a Duration to extend to.

                        method before

                        static before: (end: DateInput, duration: DurationInput) => Interval;
                        • Create an Interval from an end DateTime and a Duration to extend backwards to.

                        method contains

                        contains: (dateTime: DateTime) => boolean;
                        • Return whether this Interval contains the specified DateTime.

                        method count

                        count: (unit?: DurationUnit) => number;
                        • Returns the count of minutes, hours, days, months, or years included in the Interval, even in part. Unlike 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?'

                          Parameter unit

                          the unit of time to count.

                        method difference

                        difference: (...intervals: Interval[]) => Interval[];
                        • Return an Interval representing the span of time in this Interval that doesn't overlap with any of the specified Intervals.

                        method divideEqually

                        divideEqually: (numberOfParts: number) => Interval[];
                        • Split this Interval into the specified number of smaller intervals.

                          Parameter numberOfParts

                          The number of Intervals to divide the Interval into.

                        method engulfs

                        engulfs: (other: Interval) => boolean;
                        • Return whether this Interval engulfs the start and end of the specified Interval.

                        method equals

                        equals: (other: Interval) => boolean;
                        • Return whether this Interval has the same start and end as the specified Interval. Two DateTimes are equal if they represent the same millisecond, have the same zone and location, and are both valid.

                        method fromDateTimes

                        static fromDateTimes: (start: DateInput, end: DateInput) => Interval;
                        • Create an Interval from a start DateTime and an end DateTime. Inclusive of the start but not the end.

                        method fromISO

                        static fromISO: (text: string, options?: DateTimeOptions) => Interval;
                        • Create an Interval from an ISO 8601 string. Accepts <start>/<end>, <start>/<duration>, and <duration>/<end> formats.

                          See Also

                          • https://en.wikipedia.org/wiki/ISO_8601#Time_intervals

                        method hasSame

                        hasSame: (unit: DurationUnit) => boolean;
                        • Returns whether this Interval's start and end are both in the same unit of time

                          Parameter unit

                          the unit of time to check sameness on

                        method intersection

                        intersection: (other: Interval) => Interval | null;
                        • 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 don't intersect.

                        method invalid

                        static invalid: (reason: string, explanation?: string) => Interval;
                        • Create an invalid Interval.

                          Parameter reason

                          simple string of why this Interval is invalid. Should not contain parameters or anything else data-dependent

                          Parameter explanation

                          longer explanation, may include parameters and other useful debugging information

                        method isAfter

                        isAfter: (dateTime: DateTime) => boolean;
                        • Return whether this Interval's start is after the specified DateTime.

                        method isBefore

                        isBefore: (dateTime: DateTime) => boolean;
                        • Return whether this Interval's end is before the specified DateTime.

                        method isEmpty

                        isEmpty: () => boolean;
                        • Return whether this Interval has the same start and end DateTimes.

                        method isInterval

                        static isInterval: (o: any) => o is Interval;
                        • Check if an object is an Interval. Works across context boundaries

                        method length

                        length: (unit?: DurationUnit) => number;
                        • Returns the length of the Interval in the specified unit.

                          Parameter unit

                          the unit to return the length in.

                        method mapEndpoints

                        mapEndpoints: (mapFn: (d: DateTime) => DateTime) => Interval;
                        • Run mapFn on the interval start and end, returning a new Interval from the resulting DateTimes

                          Example 1

                          Interval.fromDateTimes(dt1, dt2).mapEndpoints(endpoint => endpoint.toUTC())

                          Example 2

                          Interval.fromDateTimes(dt1, dt2).mapEndpoints(endpoint => endpoint.plus({ hours: 2 }))

                        method merge

                        static merge: (intervals: Interval[]) => Interval[];
                        • Merge an array of Intervals into a equivalent minimal set of Intervals. Combines overlapping and adjacent Intervals.

                        method overlaps

                        overlaps: (other: Interval) => boolean;
                        • Return whether this Interval overlaps with the specified Interval

                        method set

                        set: (values?: IntervalObject) => Interval;
                        • "Sets" the start and/or end dates. Returns a newly-constructed Interval.

                        method splitAt

                        splitAt: (...dateTimes: DateTime[]) => Interval[];
                        • Split this Interval at each of the specified DateTimes

                        method splitBy

                        splitBy: (duration: DurationInput) => Interval[];
                        • Split this Interval into smaller Intervals, each of the specified length. Left over time is grouped into a smaller interval

                          Parameter duration

                          The length of each resulting interval.

                        method toDuration

                        toDuration: (
                        unit?: DurationUnit | DurationUnit[],
                        options?: DiffOptions
                        ) => Duration;
                        • Return a Duration representing the time spanned by this interval.

                          Parameter unit

                          the unit or units to include in the duration.

                          Parameter options

                          options that affect the creation of the Duration

                          Parameter

                          [options.conversionAccuracy='casual'] - the conversion system to use

                          Example 1

                          Interval.fromDateTimes(dt1, dt2).toDuration().toObject() //=> { milliseconds: 88489257 }

                          Example 2

                          Interval.fromDateTimes(dt1, dt2).toDuration('days').toObject() //=> { days: 1.0241812152777778 }

                          Example 3

                          Interval.fromDateTimes(dt1, dt2).toDuration(['hours', 'minutes']).toObject() //=> { hours: 24, minutes: 34.82095 }

                          Example 4

                          Interval.fromDateTimes(dt1, dt2).toDuration(['hours', 'minutes', 'seconds']).toObject() //=> { hours: 24, minutes: 34, seconds: 49.257 }

                          Example 5

                          Interval.fromDateTimes(dt1, dt2).toDuration('seconds').toObject() //=> { seconds: 88489.257 }

                        method toFormat

                        toFormat: (dateFormat: string, options?: { separator?: string }) => string;
                        • Returns a string representation of this Interval formatted according to the specified format string.

                          Parameter dateFormat

                          the format string. This string formats the start and end time. See DateTime.toFormat for details.

                          Parameter options

                          options

                          Parameter

                          [options.separator=' - '] - a separator to place between the start and end representations

                        method toISO

                        toISO: (options?: ToISOTimeOptions) => string;
                        • Returns an ISO 8601-compliant string representation of this Interval.

                          See Also

                          • https://en.wikipedia.org/wiki/ISO_8601#Time_intervals

                        method toISODate

                        toISODate: () => string;
                        • Returns an ISO 8601-compliant string representation of date of this Interval. The time components are ignored.

                          See Also

                          • https://en.wikipedia.org/wiki/ISO_8601#Time_intervals

                        method toISOTime

                        toISOTime: (options?: ToISOTimeOptions) => string;
                        • Returns an ISO 8601-compliant string representation of time of this Interval. The date components are ignored.

                          See Also

                          • https://en.wikipedia.org/wiki/ISO_8601#Time_intervals

                        method toString

                        toString: () => string;
                        • Returns a string representation of this Interval appropriate for debugging.

                        method union

                        union: (other: Interval) => Interval;
                        • 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.

                        method xor

                        static xor: (intervals: Interval[]) => Interval[];
                        • Return an array of Intervals representing the spans of time that only appear in one of the specified Intervals.

                        class InvalidZone

                        class InvalidZone extends Zone {}
                        • A zone that failed to parse. You should never need to instantiate this.

                        class LocalZone

                        class LocalZone extends Zone {}
                        • Represents the local zone for this JavaScript environment.

                        property instance

                        static instance: LocalZone;
                        • Get a singleton instance of the local zone

                        class Zone

                        class Zone {}

                          property isValid

                          isValid: boolean;
                          • Return whether this Zone is valid.

                          property name

                          name: string;
                          • The name of this zone.

                          property type

                          type: string;
                          • The type of zone

                          property universal

                          universal: boolean;
                          • Returns whether the offset is known to be fixed for the whole year.

                          method equals

                          equals: (other: Zone) => boolean;
                          • Return whether this Zone is equal to another zone

                            Parameter other

                            the zone to compare

                          method formatOffset

                          formatOffset: (ts: number, format: ZoneOffsetFormat) => string;
                          • Returns the offset's value as a string

                            Parameter ts

                            Epoch milliseconds for which to get the offset

                            Parameter format

                            What style of offset to return. Accepts 'narrow', 'short', or 'techie'. Returning '+6', '+06:00', or '+0600' respectively

                          method offset

                          offset: (ts: number) => number;
                          • Return the offset in minutes for this zone at the specified timestamp.

                            Parameter ts

                            Epoch milliseconds for which to compute the offset

                          method offsetName

                          offsetName: (ts: number, options: ZoneOffsetOptions) => string;
                          • Returns the offset's common name (such as EST) at the specified timestamp

                            Parameter ts

                            Epoch milliseconds for which to get the name

                            Parameter options

                            Options to affect the format

                            Parameter

                            options.format - What style of offset to return.

                            Parameter

                            options.locale - What locale to return the offset name in.

                          Interfaces

                          interface DateObject

                          interface DateObject extends DateObjectUnits, LocaleOptions {}

                            property zone

                            zone?: string | Zone;

                              interface DateObjectUnits

                              interface DateObjectUnits {}

                                property day

                                day?: number;

                                  property hour

                                  hour?: number;

                                    property millisecond

                                    millisecond?: number;

                                      property minute

                                      minute?: number;

                                        property month

                                        month?: number;

                                          property ordinal

                                          ordinal?: number;

                                            property second

                                            second?: number;

                                              property weekday

                                              weekday?: number;

                                                property weekNumber

                                                weekNumber?: number;

                                                  property weekYear

                                                  weekYear?: number;

                                                    property year

                                                    year?: number;

                                                      interface DateTimeOptions

                                                      interface DateTimeOptions extends LocaleOptions {}

                                                        property setZone

                                                        setZone?: boolean;
                                                        • Override the zone with a fixed-offset zone specified in the string itself, if it specifies one. false

                                                        property zone

                                                        zone?: string | Zone;
                                                        • Use this zone if no offset is specified in the input string itself. Will also convert the time to this zone. local

                                                        interface DiffOptions

                                                        interface DiffOptions {}

                                                          property conversionAccuracy

                                                          conversionAccuracy?: ConversionAccuracy;

                                                            interface DurationObject

                                                            interface DurationObject extends DurationObjectUnits, DurationOptions {}

                                                              interface DurationObjectUnits

                                                              interface DurationObjectUnits {}

                                                                property day

                                                                day?: number;

                                                                  property days

                                                                  days?: number;

                                                                    property hour

                                                                    hour?: number;

                                                                      property hours

                                                                      hours?: number;

                                                                        property millisecond

                                                                        millisecond?: number;

                                                                          property milliseconds

                                                                          milliseconds?: number;

                                                                            property minute

                                                                            minute?: number;

                                                                              property minutes

                                                                              minutes?: number;

                                                                                property month

                                                                                month?: number;

                                                                                  property months

                                                                                  months?: number;

                                                                                    property quarter

                                                                                    quarter?: number;

                                                                                      property quarters

                                                                                      quarters?: number;

                                                                                        property second

                                                                                        second?: number;

                                                                                          property seconds

                                                                                          seconds?: number;

                                                                                            property week

                                                                                            week?: number;

                                                                                              property weeks

                                                                                              weeks?: number;

                                                                                                property year

                                                                                                year?: number;

                                                                                                  property years

                                                                                                  years?: number;

                                                                                                    interface DurationOptions

                                                                                                    interface DurationOptions {}

                                                                                                      property conversionAccuracy

                                                                                                      conversionAccuracy?: ConversionAccuracy;

                                                                                                        property locale

                                                                                                        locale?: string;

                                                                                                          property numberingSystem

                                                                                                          numberingSystem?: NumberingSystem;

                                                                                                            interface DurationToFormatOptions

                                                                                                            interface DurationToFormatOptions extends DateTimeFormatOptions {}

                                                                                                              property floor

                                                                                                              floor?: boolean;

                                                                                                                property round

                                                                                                                round?: boolean;

                                                                                                                  interface ExplainedFormat

                                                                                                                  interface ExplainedFormat {}

                                                                                                                    property input

                                                                                                                    input: string;

                                                                                                                      property invalidReason

                                                                                                                      invalidReason?: string;

                                                                                                                        property matches

                                                                                                                        matches?: { [k: string]: any };

                                                                                                                          property rawMatches

                                                                                                                          rawMatches?: RegExpMatchArray | null;

                                                                                                                            property regex

                                                                                                                            regex?: RegExp;

                                                                                                                              property result

                                                                                                                              result?: { [k: string]: any } | null;

                                                                                                                                property tokens

                                                                                                                                tokens: Array<{ literal: boolean; val: string }>;

                                                                                                                                  property zone

                                                                                                                                  zone?: Zone | null;

                                                                                                                                    interface Features

                                                                                                                                    interface Features {}

                                                                                                                                      property intl

                                                                                                                                      intl: boolean;
                                                                                                                                      • Whether this environment supports general internationalization

                                                                                                                                      property intlTokens

                                                                                                                                      intlTokens: boolean;
                                                                                                                                      • Whether this environment supports internationalized token-based formatting/parsing

                                                                                                                                      property relative

                                                                                                                                      relative: boolean;
                                                                                                                                      • Whether this environment supports relative time formatting

                                                                                                                                      property zones

                                                                                                                                      zones: boolean;
                                                                                                                                      • Whether this environment supports IANA timezones

                                                                                                                                      interface InfoCalendarOptions

                                                                                                                                      interface InfoCalendarOptions extends InfoUnitOptions {}

                                                                                                                                        property outputCalendar

                                                                                                                                        outputCalendar?: CalendarSystem;

                                                                                                                                          interface InfoOptions

                                                                                                                                          interface InfoOptions {}

                                                                                                                                            property locale

                                                                                                                                            locale?: string;

                                                                                                                                              interface InfoUnitOptions

                                                                                                                                              interface InfoUnitOptions extends InfoOptions {}

                                                                                                                                                property numberingSystem

                                                                                                                                                numberingSystem?: NumberingSystem;

                                                                                                                                                  interface IntervalObject

                                                                                                                                                  interface IntervalObject {}

                                                                                                                                                    property end

                                                                                                                                                    end?: DateTime;

                                                                                                                                                      property start

                                                                                                                                                      start?: DateTime;

                                                                                                                                                        interface LocaleOptions

                                                                                                                                                        interface LocaleOptions {}

                                                                                                                                                          property locale

                                                                                                                                                          locale?: string;
                                                                                                                                                          • system's locale

                                                                                                                                                          property numberingSystem

                                                                                                                                                          numberingSystem?: NumberingSystem;

                                                                                                                                                            property outputCalendar

                                                                                                                                                            outputCalendar?: CalendarSystem;

                                                                                                                                                              interface ToISODateOptions

                                                                                                                                                              interface ToISODateOptions {}

                                                                                                                                                                property format

                                                                                                                                                                format?: ToISOFormat;
                                                                                                                                                                • Choose between the basic and extended format 'extended'

                                                                                                                                                                interface ToISOTimeDurationOptions

                                                                                                                                                                interface ToISOTimeDurationOptions {}

                                                                                                                                                                  property format

                                                                                                                                                                  format?: ToISOFormat;
                                                                                                                                                                  • Choose between the basic and extended format 'extended'

                                                                                                                                                                  property includePrefix

                                                                                                                                                                  includePrefix?: boolean;
                                                                                                                                                                  • Include the T prefix false

                                                                                                                                                                  property suppressMilliseconds

                                                                                                                                                                  suppressMilliseconds?: boolean;
                                                                                                                                                                  • Exclude milliseconds from the format if they're 0 false

                                                                                                                                                                  property suppressSeconds

                                                                                                                                                                  suppressSeconds?: boolean;
                                                                                                                                                                  • Exclude seconds from the format if they're 0 false

                                                                                                                                                                  interface ToISOTimeOptions

                                                                                                                                                                  interface ToISOTimeOptions extends ToISOTimeDurationOptions {}

                                                                                                                                                                    property includeOffset

                                                                                                                                                                    includeOffset?: boolean;
                                                                                                                                                                    • Include the offset, such as 'Z' or '-04:00' true

                                                                                                                                                                    interface ToRelativeCalendarOptions

                                                                                                                                                                    interface ToRelativeCalendarOptions {}

                                                                                                                                                                      property base

                                                                                                                                                                      base?: DateTime;
                                                                                                                                                                      • The DateTime to use as the basis to which this time is compared now

                                                                                                                                                                      property locale

                                                                                                                                                                      locale?: string;
                                                                                                                                                                      • Override the locale of this DateTime

                                                                                                                                                                      property numberingSystem

                                                                                                                                                                      numberingSystem?: NumberingSystem;
                                                                                                                                                                      • Override the numberingSystem of this DateTime. The Intl system may choose not to honor this.

                                                                                                                                                                      property unit

                                                                                                                                                                      unit?: ToRelativeUnit;
                                                                                                                                                                      • If omitted, the method will pick the unit.

                                                                                                                                                                      interface ToRelativeOptions

                                                                                                                                                                      interface ToRelativeOptions extends ToRelativeCalendarOptions {}

                                                                                                                                                                        property padding

                                                                                                                                                                        padding?: number;
                                                                                                                                                                        • Padding in milliseconds. This allows you to round up the result if it fits inside the threshold. Don't use in combination with {round: false} because the decimal output will include the padding. 0

                                                                                                                                                                        property round

                                                                                                                                                                        round?: boolean;
                                                                                                                                                                        • true

                                                                                                                                                                        property style

                                                                                                                                                                        style?: StringUnitLength;
                                                                                                                                                                        • long

                                                                                                                                                                        interface ToSQLOptions

                                                                                                                                                                        interface ToSQLOptions {}

                                                                                                                                                                          property includeOffset

                                                                                                                                                                          includeOffset?: boolean;
                                                                                                                                                                          • Include the offset, such as 'Z' or '-04:00' true

                                                                                                                                                                          property includeZone

                                                                                                                                                                          includeZone?: boolean;
                                                                                                                                                                          • Include the zone, such as 'America/New_York'. Overrides includeOffset. false

                                                                                                                                                                          interface ZoneOffsetOptions

                                                                                                                                                                          interface ZoneOffsetOptions {}

                                                                                                                                                                            property format

                                                                                                                                                                            format?: 'short' | 'long';
                                                                                                                                                                            • What style of offset to return.

                                                                                                                                                                            property locale

                                                                                                                                                                            locale?: string;
                                                                                                                                                                            • What locale to return the offset name in.

                                                                                                                                                                            interface ZoneOptions

                                                                                                                                                                            interface ZoneOptions {}

                                                                                                                                                                              property keepCalendarTime

                                                                                                                                                                              keepCalendarTime?: boolean;
                                                                                                                                                                              • Deprecated

                                                                                                                                                                                since 0.2.12. Use keepLocalTime instead

                                                                                                                                                                              property keepLocalTime

                                                                                                                                                                              keepLocalTime?: boolean;
                                                                                                                                                                              • 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.

                                                                                                                                                                              Type Aliases

                                                                                                                                                                              type CalendarSystem

                                                                                                                                                                              type CalendarSystem = Intl.DateTimeFormatOptions extends { calendar?: infer T }
                                                                                                                                                                              ? T
                                                                                                                                                                              :
                                                                                                                                                                              | 'buddhist'
                                                                                                                                                                              | 'chinese'
                                                                                                                                                                              | 'coptic'
                                                                                                                                                                              | 'ethioaa'
                                                                                                                                                                              | 'ethiopic'
                                                                                                                                                                              | 'gregory'
                                                                                                                                                                              | 'hebrew'
                                                                                                                                                                              | 'indian'
                                                                                                                                                                              | 'islamic'
                                                                                                                                                                              | 'islamicc'
                                                                                                                                                                              | 'iso8601'
                                                                                                                                                                              | 'japanese'
                                                                                                                                                                              | 'persian'
                                                                                                                                                                              | 'roc';

                                                                                                                                                                                type ConversionAccuracy

                                                                                                                                                                                type ConversionAccuracy = 'casual' | 'longterm';

                                                                                                                                                                                  type DateInput

                                                                                                                                                                                  type DateInput = DateTime | DateObject | Date;

                                                                                                                                                                                    type DateTimeFormatOptions

                                                                                                                                                                                    type DateTimeFormatOptions = Intl.DateTimeFormatOptions;

                                                                                                                                                                                      type DateTimeJSOptions

                                                                                                                                                                                      type DateTimeJSOptions = Omit<DateTimeOptions, 'setZone'>;

                                                                                                                                                                                        type DurationInput

                                                                                                                                                                                        type DurationInput = Duration | number | DurationObject;
                                                                                                                                                                                        • Either a Luxon Duration, a number of milliseconds, the object argument to Duration.fromObject()

                                                                                                                                                                                        type DurationUnit

                                                                                                                                                                                        type DurationUnit = keyof DurationObjectUnits;

                                                                                                                                                                                          type DurationUnits

                                                                                                                                                                                          type DurationUnits = DurationUnit | DurationUnit[];

                                                                                                                                                                                            type EraLength

                                                                                                                                                                                            type EraLength = StringUnitLength;
                                                                                                                                                                                            • Deprecated

                                                                                                                                                                                            type HourCycle

                                                                                                                                                                                            type HourCycle = 'h11' | 'h12' | 'h23' | 'h24';

                                                                                                                                                                                              type ISOTimeOptions

                                                                                                                                                                                              type ISOTimeOptions = ToISOTimeOptions;
                                                                                                                                                                                              • Deprecated

                                                                                                                                                                                                alias for backwards compatibility

                                                                                                                                                                                              type NumberingSystem

                                                                                                                                                                                              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';

                                                                                                                                                                                                type NumberUnitLength

                                                                                                                                                                                                type NumberUnitLength = 'numeric' | '2-digit';

                                                                                                                                                                                                  type StringUnitLength

                                                                                                                                                                                                  type StringUnitLength = 'narrow' | 'short' | 'long';

                                                                                                                                                                                                    type ToISOFormat

                                                                                                                                                                                                    type ToISOFormat = 'basic' | 'extended';

                                                                                                                                                                                                      type ToRelativeUnit

                                                                                                                                                                                                      type ToRelativeUnit =
                                                                                                                                                                                                      | 'years'
                                                                                                                                                                                                      | 'quarters'
                                                                                                                                                                                                      | 'months'
                                                                                                                                                                                                      | 'weeks'
                                                                                                                                                                                                      | 'days'
                                                                                                                                                                                                      | 'hours'
                                                                                                                                                                                                      | 'minutes'
                                                                                                                                                                                                      | 'seconds';

                                                                                                                                                                                                        type UnitLength

                                                                                                                                                                                                        type UnitLength = StringUnitLength | NumberUnitLength;

                                                                                                                                                                                                          type UnitOptions

                                                                                                                                                                                                          type UnitOptions = InfoUnitOptions;
                                                                                                                                                                                                          • Deprecated

                                                                                                                                                                                                          type ZoneOffsetFormat

                                                                                                                                                                                                          type ZoneOffsetFormat = 'narrow' | 'short' | 'techie';
                                                                                                                                                                                                          • What style of offset to return. Returning '+6', '+06:00', or '+0600' respectively

                                                                                                                                                                                                          Namespaces

                                                                                                                                                                                                          namespace Info

                                                                                                                                                                                                          namespace Info {}
                                                                                                                                                                                                          • The Info "class" contains static methods for retrieving general time and date related data. For example, it has methods for finding out if a time zone has a DST, for listing the months in any supported locale, and for discovering which of Luxon features are available in the current environment.

                                                                                                                                                                                                          function eras

                                                                                                                                                                                                          eras: (length?: StringUnitLength, options?: InfoOptions) => string[];
                                                                                                                                                                                                          • Return an array of eras, such as ['BC', 'AD']. The locale can be specified, but the calendar system is always Gregorian.

                                                                                                                                                                                                            Parameter length

                                                                                                                                                                                                            the length of the era representation, such as "short" or "long".

                                                                                                                                                                                                            Parameter options

                                                                                                                                                                                                            options

                                                                                                                                                                                                            Parameter

                                                                                                                                                                                                            [options.locale] - the locale code

                                                                                                                                                                                                            Example 1

                                                                                                                                                                                                            Info.eras() //=> [ 'BC', 'AD' ]

                                                                                                                                                                                                            Example 2

                                                                                                                                                                                                            Info.eras('long') //=> [ 'Before Christ', 'Anno Domini' ]

                                                                                                                                                                                                            Example 3

                                                                                                                                                                                                            Info.eras('long', { locale: 'fr' }) //=> [ 'avant Jésus-Christ', 'après Jésus-Christ' ]

                                                                                                                                                                                                          function features

                                                                                                                                                                                                          features: () => Features;
                                                                                                                                                                                                          • Return the set of available features in this environment. Some features of Luxon are not available in all environments. For example, on older browsers, timezone support is not available. Use this function to figure out if that's the case. Keys: * zones: whether this environment supports IANA timezones * intlTokens: whether this environment supports internationalized token-based formatting/parsing * intl: whether this environment supports general internationalization * relative: whether this environment supports relative time formatting

                                                                                                                                                                                                          function hasDST

                                                                                                                                                                                                          hasDST: (zone?: string | Zone) => boolean;
                                                                                                                                                                                                          • Return whether the specified zone contains a DST.

                                                                                                                                                                                                            Parameter zone

                                                                                                                                                                                                            Zone to check. Defaults to the environment's local zone.

                                                                                                                                                                                                          function isValidIANAZone

                                                                                                                                                                                                          isValidIANAZone: (zone: string) => boolean;
                                                                                                                                                                                                          • Return whether the specified zone is a valid IANA specifier.

                                                                                                                                                                                                            Parameter zone

                                                                                                                                                                                                            Zone to check

                                                                                                                                                                                                          function meridiems

                                                                                                                                                                                                          meridiems: (options?: InfoOptions) => string[];
                                                                                                                                                                                                          • Return an array of meridiems.

                                                                                                                                                                                                            Parameter options

                                                                                                                                                                                                            options

                                                                                                                                                                                                            Parameter

                                                                                                                                                                                                            [options.locale] - the locale code

                                                                                                                                                                                                            Example 1

                                                                                                                                                                                                            Info.meridiems() //=> [ 'AM', 'PM' ]

                                                                                                                                                                                                            Example 2

                                                                                                                                                                                                            Info.meridiems({ locale: 'my' }) //=> [ 'နံနက်', 'ညနေ' ]

                                                                                                                                                                                                          function months

                                                                                                                                                                                                          months: (length?: UnitLength, options?: InfoCalendarOptions) => string[];
                                                                                                                                                                                                          • Return an array of standalone month names.

                                                                                                                                                                                                            Parameter length

                                                                                                                                                                                                            the length of the month representation

                                                                                                                                                                                                            Parameter options

                                                                                                                                                                                                            options

                                                                                                                                                                                                            Parameter

                                                                                                                                                                                                            [options.locale] - the locale code

                                                                                                                                                                                                            Parameter

                                                                                                                                                                                                            [options.numberingSystem=null] - the numbering system

                                                                                                                                                                                                            Parameter

                                                                                                                                                                                                            [options.outputCalendar='gregory'] - the calendar

                                                                                                                                                                                                            Example 1

                                                                                                                                                                                                            Info.months()[0] //=> 'January'

                                                                                                                                                                                                            Example 2

                                                                                                                                                                                                            Info.months('short')[0] //=> 'Jan'

                                                                                                                                                                                                            Example 3

                                                                                                                                                                                                            Info.months('numeric')[0] //=> '1'

                                                                                                                                                                                                            Example 4

                                                                                                                                                                                                            Info.months('short', { locale: 'fr-CA' } )[0] //=> 'janv.'

                                                                                                                                                                                                            Example 5

                                                                                                                                                                                                            Info.months('numeric', { locale: 'ar' })[0] //=> '١'

                                                                                                                                                                                                            Example 6

                                                                                                                                                                                                            Info.months('long', { outputCalendar: 'islamic' })[0] //=> 'Rabiʻ I'

                                                                                                                                                                                                            See Also

                                                                                                                                                                                                            • https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat

                                                                                                                                                                                                          function monthsFormat

                                                                                                                                                                                                          monthsFormat: (length?: UnitLength, options?: InfoCalendarOptions) => string[];
                                                                                                                                                                                                          • Return an array of format month names. Format months differ from standalone months in that they're meant to appear next to the day of the month. In some languages, that changes the string. See months

                                                                                                                                                                                                            Parameter length

                                                                                                                                                                                                            the length of the month representation

                                                                                                                                                                                                            Parameter options

                                                                                                                                                                                                            options

                                                                                                                                                                                                            Parameter

                                                                                                                                                                                                            [options.locale] - the locale code

                                                                                                                                                                                                            Parameter

                                                                                                                                                                                                            [options.numberingSystem=null] - the numbering system

                                                                                                                                                                                                            Parameter

                                                                                                                                                                                                            [options.outputCalendar='gregory'] - the calendar

                                                                                                                                                                                                          function normalizeZone

                                                                                                                                                                                                          normalizeZone: (input?: number | string | Zone) => Zone;
                                                                                                                                                                                                          • Converts the input into a Zone instance.

                                                                                                                                                                                                            * If input is already a Zone instance, it is returned unchanged. * If input is a string containing a valid time zone name, a Zone instance with that name is returned. * If input is a string that doesn't refer to a known time zone, a Zone instance with Zone.isValid == false is returned. * If `input is a number, a Zone instance with the specified fixed offset in minutes is returned. * If input is null or undefined, the default zone is returned.

                                                                                                                                                                                                            Parameter input

                                                                                                                                                                                                            the value to be converted

                                                                                                                                                                                                          function weekdays

                                                                                                                                                                                                          weekdays: (length?: StringUnitLength, options?: InfoUnitOptions) => string[];
                                                                                                                                                                                                          • Return an array of standalone week names.

                                                                                                                                                                                                            Parameter length

                                                                                                                                                                                                            the length of the weekday representation

                                                                                                                                                                                                            Parameter options

                                                                                                                                                                                                            options

                                                                                                                                                                                                            Parameter

                                                                                                                                                                                                            [options.locale] - the locale code

                                                                                                                                                                                                            Parameter

                                                                                                                                                                                                            [options.numberingSystem=null] - the numbering system

                                                                                                                                                                                                            Example 1

                                                                                                                                                                                                            Info.weekdays()[0] //=> 'Monday'

                                                                                                                                                                                                            Example 2

                                                                                                                                                                                                            Info.weekdays('short')[0] //=> 'Mon'

                                                                                                                                                                                                            Example 3

                                                                                                                                                                                                            Info.weekdays('short', { locale: 'fr-CA' })[0] //=> 'lun.'

                                                                                                                                                                                                            Example 4

                                                                                                                                                                                                            Info.weekdays('short', { locale: 'ar' })[0] //=> 'الاثنين'

                                                                                                                                                                                                            See Also

                                                                                                                                                                                                            • https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat

                                                                                                                                                                                                          function weekdaysFormat

                                                                                                                                                                                                          weekdaysFormat: (
                                                                                                                                                                                                          length?: StringUnitLength,
                                                                                                                                                                                                          options?: InfoUnitOptions
                                                                                                                                                                                                          ) => string[];
                                                                                                                                                                                                          • Return an array of format week names. Format weekdays differ from standalone weekdays in that they're meant to appear next to more date information. In some languages, that changes the string. See weekdays

                                                                                                                                                                                                            Parameter length

                                                                                                                                                                                                            the length of the weekday representation

                                                                                                                                                                                                            Parameter options

                                                                                                                                                                                                            options

                                                                                                                                                                                                            Parameter

                                                                                                                                                                                                            [options.locale=null] - the locale code

                                                                                                                                                                                                            Parameter

                                                                                                                                                                                                            [options.numberingSystem=null] - the numbering system

                                                                                                                                                                                                          namespace Settings

                                                                                                                                                                                                          namespace Settings {}
                                                                                                                                                                                                          • Settings contains static getters and setters that control Luxon's overall behavior. Luxon is a simple library with few options, but the ones it does have live here.

                                                                                                                                                                                                          variable defaultLocale

                                                                                                                                                                                                          let defaultLocale: string;
                                                                                                                                                                                                          • The default locale to create DateTimes with. Does not affect existing instances.

                                                                                                                                                                                                          variable defaultNumberingSystem

                                                                                                                                                                                                          let defaultNumberingSystem: string;
                                                                                                                                                                                                          • The default numbering system to create DateTimes with. Does not affect existing instances.

                                                                                                                                                                                                          variable defaultOutputCalendar

                                                                                                                                                                                                          let defaultOutputCalendar: string;
                                                                                                                                                                                                          • The default output calendar to create DateTimes with. Does not affect existing instances.

                                                                                                                                                                                                          variable defaultZone

                                                                                                                                                                                                          const defaultZone: Zone;
                                                                                                                                                                                                          • The default time zone object to create DateTimes in. Does not affect existing instances. Change by setting defaultZoneName

                                                                                                                                                                                                          variable defaultZoneName

                                                                                                                                                                                                          let defaultZoneName: string;
                                                                                                                                                                                                          • The default time zone to create DateTimes in. Does not affect existing instances. Set this to change defaultZone

                                                                                                                                                                                                          variable throwOnInvalid

                                                                                                                                                                                                          let throwOnInvalid: boolean;
                                                                                                                                                                                                          • Whether Luxon will throw when it encounters invalid DateTimes, Durations, or Intervals

                                                                                                                                                                                                          function now

                                                                                                                                                                                                          now: () => number;
                                                                                                                                                                                                          • The current function for returning the current timestamp. The function should return a number, which will be interpreted as an Epoch millisecond count

                                                                                                                                                                                                            Example 1

                                                                                                                                                                                                            Settings.now = () => Date.now() + 3000 // pretend it is 3 seconds in the future

                                                                                                                                                                                                            Example 2

                                                                                                                                                                                                            Settings.now = () => 0 // always pretend it's Jan 1, 1970 at midnight in UTC time

                                                                                                                                                                                                          function resetCaches

                                                                                                                                                                                                          resetCaches: () => void;
                                                                                                                                                                                                          • Reset Luxon's global caches. Should only be necessary in testing scenarios.

                                                                                                                                                                                                          Package Files (9)

                                                                                                                                                                                                          Dependencies (0)

                                                                                                                                                                                                          No dependencies.

                                                                                                                                                                                                          Dev Dependencies (0)

                                                                                                                                                                                                          No dev dependencies.

                                                                                                                                                                                                          Peer Dependencies (0)

                                                                                                                                                                                                          No peer dependencies.

                                                                                                                                                                                                          Badge

                                                                                                                                                                                                          To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                                                                                                                                                                          You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@types/luxon.

                                                                                                                                                                                                          • Markdown
                                                                                                                                                                                                            [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@types/luxon)
                                                                                                                                                                                                          • HTML
                                                                                                                                                                                                            <a href="https://www.jsdocs.io/package/@types/luxon"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>