@types/luxon

  • Version 2.3.2
  • Published
  • 113 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 {}

    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;

    property DATETIME_FULL_WITH_SECONDS

    static readonly DATETIME_FULL_WITH_SECONDS: Intl.DateTimeFormatOptions;

    property DATETIME_HUGE

    static readonly DATETIME_HUGE: Intl.DateTimeFormatOptions;
    • DateTime.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;
    • DateTime.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;

    property DATETIME_MED_WITH_SECONDS

    static readonly DATETIME_MED_WITH_SECONDS: Intl.DateTimeFormatOptions;

    property DATETIME_MED_WITH_WEEKDAY

    static readonly DATETIME_MED_WITH_WEEKDAY: Intl.DateTimeFormatOptions;

    property DATETIME_SHORT

    static readonly DATETIME_SHORT: Intl.DateTimeFormatOptions;

    property DATETIME_SHORT_WITH_SECONDS

    static readonly DATETIME_SHORT_WITH_SECONDS: Intl.DateTimeFormatOptions;

    property day

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

      Example 1

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

    property daysInMonth

    readonly daysInMonth: PossibleDaysInMonth;
    • 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

    readonly daysInYear: PossibleDaysInYear;
    • 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

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

      Example 1

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

    property invalidExplanation

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

    property invalidReason

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

    property isInDST

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

    property isInLeapYear

    readonly 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

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

    property isValid

    readonly 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

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

    property millisecond

    readonly 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

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

      Example 1

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

    property month

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

      Example 1

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

    property monthLong

    readonly 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

    readonly 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

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

    property offset

    readonly 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

    readonly 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

    readonly 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

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

      Example 1

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

    property outputCalendar

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

    property quarter

    readonly quarter: QuarterNumbers;
    • Get the quarter

      Example 1

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

    property second

    readonly second: SecondNumbers;
    • 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;

    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;

    property TIME_WITH_SECONDS

    static readonly TIME_WITH_SECONDS: Intl.DateTimeFormatOptions;

    property TIME_WITH_SHORT_OFFSET

    static readonly TIME_WITH_SHORT_OFFSET: Intl.DateTimeFormatOptions;

    property weekday

    readonly weekday: WeekdayNumbers;
    • 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

    readonly 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

    readonly 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

    readonly weekNumber: WeekNumbers;
    • 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

    readonly weeksInWeekYear: PossibleWeeksInYear;
    • 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

    readonly weekYear: number;
    • Get the week year

      Example 1

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

      See Also

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

    property year

    readonly year: number;
    • Get the year

      Example 1

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

    property zone

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

    property zoneName

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

    method diff

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

      Parameter otherDateTime

      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. Defaults to ['milliseconds'].

      Parameter opts

      options that affect the creation of the Duration

      Parameter

      opts.conversionAccuracy - the conversion system to use. Defaults to 'casual'.

      Example 1

      var 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, opts?: DiffOptions) => Duration;
    • Return the difference between this DateTime and right now. See DateTime.diff

      Parameter unit

      the unit or units units (such as 'hours' or 'days') to include in the duration. Defaults to ['milliseconds'].

      Parameter opts

      options that affect the creation of the Duration

      Parameter

      opts.conversionAccuracy - the conversion system to use. Defaults to 'casual'.

    method endOf

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

      Parameter unit

      The unit to go to the end of. Can be 'year', 'quarter', 'month', 'week', 'day', 'hour', 'minute', 'second', or 'millisecond'.

      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 iff they represent the same millisecond, have the same zone and location, and are both valid. To compare just the millisecond values, use +dt1 === +dt2.

      Parameter other

      the other DateTime

    method fromFormat

    static fromFormat: (
    text: string,
    fmt: 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. For a table of tokens and their interpretations, see [here](https://moment.github.io/luxon/#/parsing?id=table-of-tokens).

      Parameter text

      the string to parse

      Parameter fmt

      the format the string is expected to be in (see the link below for the formats)

      Parameter opts

      options to affect the creation

      Parameter

      opts.zone - use this zone if no offset is specified in the input string itself. Will also convert the DateTime to this zone. Defaults to 'local'.

      Parameter

      opts.setZone - override the zone with a zone specified in the string itself, if it specifies one. Defaults to false.

      Parameter

      opts.locale - a locale string to use when parsing. Will also set the DateTime to this locale. Defaults to 'en-US'.

      Parameter

      opts.numberingSystem - the numbering system to use when parsing. Will also set the resulting DateTime to this numbering system

      Parameter

      opts.outputCalendar - the output calendar to set on the resulting DateTime instance

    method fromFormatExplain

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

      Parameter text

      the string to parse

      Parameter fmt

      the format the string is expected to be in (see description)

      Parameter options

      options taken by fromFormat()

    method fromHTTP

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

      Parameter text

      the HTTP header date

      Parameter opts

      options to affect the creation

      Parameter

      opts.zone - convert the time to this zone. Since HTTP dates are always in UTC, this has no effect on the interpretation of string,merely the zone the resulting DateTime is expressed in. Defaults to 'local'.

      Parameter

      opts.setZone - override the zone with the fixed-offset zone specified in the string. For HTTP dates, this is always UTC, so this option is equivalent to setting the zone option to 'utc', but this option is included for consistency with similar methods. Defaults to false.

      Parameter

      opts.locale - a locale to set on the resulting DateTime instance. Defaults to 'system's locale'.

      Parameter

      opts.outputCalendar - the output calendar to set on the resulting DateTime instance

      Parameter

      opts.numberingSystem - the numbering system to set on the resulting DateTime instance

      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, opts?: DateTimeOptions) => DateTime;
    • Create a DateTime from an ISO 8601 string

      Parameter text

      the ISO string

      Parameter opts

      options to affect the creation

      Parameter

      opts.zone - use this zone if no offset is specified in the input string itself. Will also convert the time to this zone. Defaults to 'local'.

      Parameter

      opts.setZone - override the zone with a fixed-offset zone specified in the string itself, if it specifies one. Defaults to false.

      Parameter

      opts.locale - a locale to set on the resulting DateTime instance. Defaults to 'system's locale'.

      Parameter

      opts.outputCalendar - the output calendar to set on the resulting DateTime instance

      Parameter

      opts.numberingSystem - the numbering system to set on the resulting DateTime instance

      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?: { zone?: string | Zone }) => DateTime;
    • Create a DateTime from a JavaScript Date object. Uses the default zone.

      Parameter date

      a JavaScript Date object

      Parameter options

      configuration options for the DateTime

      Parameter

      options.zone - the zone to place the DateTime into

    method fromMillis

    static fromMillis: (
    milliseconds: number,
    options?: DateTimeJSOptions
    ) => 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.

      Parameter milliseconds

      a number of milliseconds since 1970 UTC

      Parameter options

      configuration options for the DateTime

      Parameter

      options.zone - the zone to place the DateTime into. Defaults to 'local'.

      Parameter

      options.locale - a locale to set on the resulting DateTime instance

      Parameter

      options.outputCalendar - the output calendar to set on the resulting DateTime instance

      Parameter

      options.numberingSystem - the numbering system to set on the resulting DateTime instance

    method fromObject

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

      Parameter obj

      the object to create the DateTime from

      Parameter

      obj.year - a year, such as 1987

      Parameter

      obj.month - a month, 1-12

      Parameter

      obj.day - a day of the month, 1-31, depending on the month

      Parameter

      obj.ordinal - day of the year, 1-365 or 366

      Parameter

      obj.weekYear - an ISO week year

      Parameter

      obj.weekNumber - an ISO week number, between 1 and 52 or 53, depending on the year

      Parameter

      obj.weekday - an ISO weekday, 1-7, where 1 is Monday and 7 is Sunday

      Parameter

      obj.hour - hour of the day, 0-23

      Parameter

      obj.minute - minute of the hour, 0-59

      Parameter

      obj.second - second of the minute, 0-59

      Parameter

      obj.millisecond - millisecond of the second, 0-999

      Parameter opts

      options for creating this DateTime

      Parameter

      opts.zone - interpret the numbers in the context of a particular zone. Can take any value taken as the first argument to setZone(). Defaults to 'local'.

      Parameter

      opts.locale - a locale to set on the resulting DateTime instance. Defaults to 'system's locale'.

      Parameter

      opts.outputCalendar - the output calendar to set on the resulting DateTime instance

      Parameter

      opts.numberingSystem - the numbering system to set on the resulting DateTime instance

      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, opts?: DateTimeOptions) => DateTime;
    • Create a DateTime from an RFC 2822 string

      Parameter text

      the RFC 2822 string

      Parameter opts

      options to affect the creation

      Parameter

      opts.zone - convert the time to this zone. Since the offset is always specified in the string itself, this has no effect on the interpretation of string, merely the zone the resulting DateTime is expressed in. Defaults to 'local'

      Parameter

      opts.setZone - override the zone with a fixed-offset zone specified in the string itself, if it specifies one. Defaults to false.

      Parameter

      opts.locale - a locale to set on the resulting DateTime instance. Defaults to 'system's locale'.

      Parameter

      opts.outputCalendar - the output calendar to set on the resulting DateTime instance

      Parameter

      opts.numberingSystem - the numbering system to set on the resulting DateTime instance

      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?: DateTimeJSOptions) => 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.

      Parameter seconds

      a number of seconds since 1970 UTC

      Parameter options

      configuration options for the DateTime

      Parameter

      options.zone - the zone to place the DateTime into. Defaults to 'local'.

      Parameter

      options.locale - a locale to set on the resulting DateTime instance

      Parameter

      options.outputCalendar - the output calendar to set on the resulting DateTime instance

      Parameter

      options.numberingSystem - the numbering system to set on the resulting DateTime instance

    method fromSQL

    static fromSQL: (text: string, opts?: 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

      Parameter text

      the string to parse

      Parameter opts

      options to affect the creation

      Parameter

      opts.zone - use this zone if no offset is specified in the input string itself. Will also convert the DateTime to this zone. Defaults to 'local'.

      Parameter

      opts.setZone - override the zone with a zone specified in the string itself, if it specifies one. Defaults to false.

      Parameter

      opts.locale - a locale string to use when parsing. Will also set the DateTime to this locale. Defaults to 'en-US'.

      Parameter

      opts.numberingSystem - the numbering system to use when parsing. Will also set the resulting DateTime to this numbering system

      Parameter

      opts.outputCalendar - the output calendar to set on the resulting DateTime instance

      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;
    • Deprecated

      use fromFormat instead

    method fromStringExplain

    static fromStringExplain: (
    text: string,
    fmt: string,
    options?: DateTimeOptions
    ) => ExplainedFormat;
    • Deprecated

      use fromFormatExplain instead

    method get

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

      Parameter unit

      a unit such as 'minute' or 'day'

      Example 1

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

      Example 2

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

    method hasSame

    hasSame: (otherDateTime: DateTime, unit: DateTimeUnit) => boolean;
    • Return whether this DateTime is in the same unit of time as another DateTime. Note that time zones are **ignored** in this comparison, which compares the **local** calendar time. Use DateTime.setZone to convert one of the dates if needed.

      Parameter otherDateTime

      the other DateTime

      Parameter unit

      the unit of time to check sameness on

      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. Defaults to null.

    method isDateTime

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

      Parameter o

    method local

    static local: {
    (
    year: number,
    month: number,
    day: number,
    hour: number,
    minute: number,
    second: number,
    millisecond: number,
    opts?: DateTimeJSOptions
    ): DateTime;
    (
    year: number,
    month: number,
    day: number,
    hour: number,
    minute: number,
    second: number,
    opts?: DateTimeJSOptions
    ): DateTime;
    (
    year: number,
    month: number,
    day: number,
    hour: number,
    minute: number,
    opts?: DateTimeJSOptions
    ): DateTime;
    (
    year: number,
    month: number,
    day: number,
    hour: number,
    opts?: DateTimeJSOptions
    ): DateTime;
    (
    year: number,
    month: number,
    day: number,
    opts?: DateTimeJSOptions
    ): DateTime;
    (year: number, month: number, opts?: DateTimeJSOptions): DateTime;
    (year: number, opts?: DateTimeJSOptions): DateTime;
    (opts?: DateTimeJSOptions): 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({ zone: "America/New_York" }) //~> now, in US east coast time

      Example 3

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

      Example 4

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

      Example 5

      DateTime.local(2017, 3, 12, { locale: "fr") //~> 2017-03-12T00:00:00, with a French locale

      Example 6

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

      Example 7

      DateTime.local(2017, 3, 12, 5, { zone: "utc" }) //~> 2017-03-12T05:00:00, in UTC

      Example 8

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

      Example 9

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

      Example 10

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

    method max

    static max: (...dateTimes: DateTime[]) => DateTime;
    • Return the max of several date times

      Parameter dateTimes

      the DateTimes from which to choose the maximum

    method min

    static min: (...dateTimes: DateTime[]) => DateTime;
    • Return the min of several date times

      Parameter dateTimes

      the DateTimes from which to choose the minimum

    method minus

    minus: (duration: DurationLike) => DateTime;
    • See DateTime.plus

      Parameter duration

      The amount to subtract. Either a Luxon Duration, a number of milliseconds, the object argument to Duration.fromObject()

    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: DurationLike) => 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.

      Parameter duration

      The amount to add. Either a Luxon Duration, a number of milliseconds, the object argument to Duration.fromObject()

      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, numberingSystem, or outputCalendar. Returns a newly-constructed DateTime.

      Parameter properties

      the properties to set

      Example 1

      DateTime.local(2017, 5, 25).reconfigure({ locale: 'en-GB' })

    method resolvedLocaleOptions

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

      Parameter opts

      the same options as toLocaleString

    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 DateTime.reconfigure and DateTime.setZone.

      Parameter values

      a mapping of units to numbers

      Example 1

      dt.set({ year: 2017 })

      Example 2

      dt.set({ hour: 8, minute: 30 })

      Example 3

      dt.set({ weekday: 5 })

      Example 4

      dt.set({ year: 2005, ordinal: 234 })

    method setLocale

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

      Example 1

      DateTime.local(2017, 5, 25).setLocale('en-GB')

    method setZone

    setZone: (zone?: string | Zone, opts?: 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 DateTime.plus. You may wish to use DateTime.toLocal and DateTime.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 DateTime.Zone class. Defaults to 'local'.

      Parameter opts

      options

      Parameter

      opts.keepLocalTime - If true, adjust the underlying time so that the local time stays the same, but in the target zone. You should rarely need this. Defaults to false.

    method startOf

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

      Parameter unit

      The unit to go to the beginning of. Can be 'year', 'quarter', 'month', 'week', 'day', 'hour', 'minute', 'second', or 'millisecond'.

      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: (fmt: string, opts?: LocaleOptions) => string;
    • Returns a string representation of this DateTime formatted according to the specified format string. **You may not want this.** See DateTime.toLocaleString for a more flexible formatting tool. For a table of tokens and their interpretations, see [here](https://moment.github.io/luxon/#/formatting?id=table-of-tokens). Defaults to en-US if no locale has been specified, regardless of the system's locale.

      Parameter fmt

      the format string

      Parameter opts

      opts to override the configuration options on this DateTime

      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'

    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: (opts?: ToISOTimeOptions) => string;
    • Returns an ISO 8601-compliant string representation of this DateTime

      Parameter opts

      options

      Parameter

      opts.suppressMilliseconds - exclude milliseconds from the format if they're 0. Defaults to false.

      Parameter

      opts.suppressSeconds - exclude seconds from the format if they're 0. Defaults to false.

      Parameter

      opts.includeOffset - include the offset, such as 'Z' or '-04:00'. Defaults to true.

      Parameter

      opts.format - choose between the basic and extended format. Defaults to 'extended'.

      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: (opts?: ToISODateOptions) => string;
    • Returns an ISO 8601-compliant string representation of this DateTime's date component

      Parameter opts

      options

      Parameter

      opts.format - choose between the basic and extended format. Defaults to 'extended'.

      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: (ops?: ToISOTimeOptions) => string;
    • Returns an ISO 8601-compliant string representation of this DateTime's time component

      Parameter opts

      options

      Parameter

      opts.suppressMilliseconds - exclude milliseconds from the format if they're 0. Defaults to false.

      Parameter

      opts.suppressSeconds - exclude seconds from the format if they're 0. Defaults to false.

      Parameter

      opts.includeOffset - include the offset, such as 'Z' or '-04:00'. Defaults to true.

      Parameter

      opts.includePrefix - include the T prefix. Defaults to false.

      Parameter

      opts.format - choose between the basic and extended format. Defaults to 'extended'.

      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.

    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: (opts?: DateTimeFormatOptions) => Intl.DateTimeFormatPart[];
    • 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

      Parameter opts

      Intl.DateTimeFormat constructor options, same as toLocaleString.

      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: (
    formatOpts?: DateTimeFormatOptions,
    opts?: LocaleOptions
    ) => 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 of the DateTime in the assigned locale. Defaults to the system's locale if no locale has been specified

      Parameter formatOpts

      Intl.DateTimeFormat constructor options and configuration options

      Parameter opts

      opts to override the configuration options on this DateTime

      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', hourCycle: 'h23' }); //=> '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: (opts?: { includeConfig?: boolean | undefined }) => ToObjectOutput;
    • Returns a JavaScript object with this DateTime's year, month, day, and so on.

      Parameter opts

      options for generating the object

      Parameter

      opts.includeConfig - include configuration attributes in the output. Defaults to false.

      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.

      Parameter options

      options that affect the output

      Parameter

      options.base - the DateTime to use as the basis to which this time is compared. Defaults to now.

      Parameter

      options.style - the style of units, must be "long", "short", or "narrow". Defaults to long.

      Parameter

      options.unit - use a specific unit or array of units; if omitted, or an array, the method will pick the best unit. Use an array or one of "years", "quarters", "months", "weeks", "days", "hours", "minutes", or "seconds"

      Parameter

      options.round - whether to round the numbers in the output. Defaults to true.

      Parameter

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

      Parameter

      options.locale - override the locale of this DateTime

      Parameter

      options.numberingSystem - override the numberingSystem of this DateTime. The Intl system may choose not to honor this

      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.

      Parameter options

      options that affect the output

      Parameter

      options.base - the DateTime to use as the basis to which this time is compared. Defaults to now.

      Parameter

      options.locale - override the locale of this DateTime

      Parameter

      options.unit - use a specific unit; if omitted, the method will pick the unit. Use one of "years", "quarters", "months", "weeks", or "days"

      Parameter

      options.numberingSystem - override the numberingSystem of this DateTime. The Intl system may choose not to honor this

      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: (opts?: ToSQLOptions) => string;
    • Returns a string representation of this DateTime appropriate for use in SQL DateTime

      Parameter opts

      options

      Parameter

      opts.includeZone - include the zone, such as 'America/New_York'. Overrides includeOffset. Defaults to false.

      Parameter

      opts.includeOffset - include the offset, such as 'Z' or '-04:00'. Defaults to true.

      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: (opts?: ToSQLOptions) => string;
    • Returns a string representation of this DateTime appropriate for use in SQL Time

      Parameter opts

      options

      Parameter

      opts.includeZone - include the zone, such as 'America/New_York'. Overrides includeOffset. Defaults to false.

      Parameter

      opts.includeOffset - include the offset, such as 'Z' or '-04:00'. Defaults to true.

      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 toUnixInteger

    toUnixInteger: () => number;
    • Returns the epoch seconds (as a whole number) of this DateTime.

    method toUTC

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

      Equivalent to DateTime.setZone('utc')

      Parameter offset

      optionally, an offset from UTC in minutes. Defaults to 0.

      Parameter opts

      options to pass to setZone(). Defaults to {}.

    method until

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

      Parameter otherDateTime

      the other end point of the Interval

    method utc

    static utc: {
    (
    year: number,
    month: number,
    day: number,
    hour: number,
    minute: number,
    second: number,
    millisecond: number,
    options?: LocaleOptions
    ): DateTime;
    (
    year: number,
    month: number,
    day: number,
    hour: number,
    minute: number,
    second: number,
    options?: LocaleOptions
    ): DateTime;
    (
    year: number,
    month: number,
    day: number,
    hour: number,
    minute: number,
    options?: LocaleOptions
    ): DateTime;
    (
    year: number,
    month: number,
    day: number,
    hour: number,
    options?: LocaleOptions
    ): DateTime;
    (
    year: number,
    month: number,
    day: number,
    options?: LocaleOptions
    ): DateTime;
    (year: number, month: number, options?: LocaleOptions): DateTime;
    (year: number, options?: LocaleOptions): DateTime;
    (options?: LocaleOptions): 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

      Parameter options

      configuration options for the DateTime

      Parameter

      options.locale - a locale to set on the resulting DateTime instance

      Parameter

      options.outputCalendar - the output calendar to set on the resulting DateTime instance

      Parameter

      options.numberingSystem - the numbering system to set on the resulting DateTime instance

      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, { locale: "fr" } ) //~> 2017-03-12T05:45:00Z with a French locale

      Example 8

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

      Example 9

      DateTime.utc(2017, 3, 12, 5, 45, 10, 765, { locale: "fr") //~> 2017-03-12T05:45:10.765Z with a French locale

    method valueOf

    valueOf: () => number;

    class Duration

    class Duration {}

    property days

    readonly days: number;
    • Get the days.

    property hours

    readonly hours: number;
    • Get the hours.

    property invalidExplanation

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

    property invalidReason

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

    property isValid

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

    property locale

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

    property milliseconds

    readonly milliseconds: number;
    • Get the milliseconds.

    property minutes

    readonly minutes: number;
    • Get the minutes.

    property months

    readonly months: number;
    • Get the months.

    property numberingSystem

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

    property quarters

    readonly quarters: number;
    • Get the quarters.

    property seconds

    readonly seconds: number;
    • Get the seconds.

    property weeks

    readonly weeks: number;
    • Get the weeks

    property years

    readonly years: number;
    • Get the years.

    method as

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

      Parameter unit

      a unit such as 'minutes' or 'days'

      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 iff they have the same units and the same values for each unit.

      Parameter other

    method fromDurationLike

    static fromDurationLike: (durationLike: DurationLike) => Duration;
    • Create a Duration from DurationLike.

      Parameter durationLike

      Either a Luxon Duration, a number of milliseconds, or the object argument to Duration.fromObject()

    method fromISO

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

      Parameter text

      text to parse

      Parameter opts

      options for parsing

      Parameter

      opts.locale - the locale to use. Defaults to 'en-US'.

      Parameter

      opts.numberingSystem - the numbering system to use

      Parameter

      opts.conversionAccuracy - the conversion system to use. Defaults to 'casual'.

      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, opts?: DurationOptions) => Duration;
    • Create a Duration from an ISO 8601 time string.

      Parameter text

      text to parse

      Parameter opts

      options for parsing

      Parameter

      opts.locale - the locale to use. Defaults to 'en-US'.

      Parameter

      opts.numberingSystem - the numbering system to use

      Parameter

      opts.conversionAccuracy - the conversion system to use. Defaults to 'casual'.

      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, opts?: DurationOptions) => Duration;
    • Create Duration from a number of milliseconds.

      Parameter count

      of milliseconds

      Parameter opts

      options for parsing

      Parameter

      opts.locale - the locale to use

      Parameter

      opts.numberingSystem - the numbering system to use

      Parameter

      opts.conversionAccuracy - the conversion system to use

    method fromObject

    static fromObject: (obj: DurationLikeObject, opts?: DurationOptions) => Duration;
    • Create a Duration from a JavaScript object with keys like 'years' and 'hours'. If this object is empty then a zero milliseconds duration is returned.

      Parameter obj

      the object to create the DateTime from

      Parameter

      obj.years

      Parameter

      obj.quarters

      Parameter

      obj.months

      Parameter

      obj.weeks

      Parameter

      obj.days

      Parameter

      obj.hours

      Parameter

      obj.minutes

      Parameter

      obj.seconds

      Parameter

      obj.milliseconds

      Parameter opts

      options for creating this Duration. Defaults to {}.

      Parameter

      opts.locale - the locale to use. Defaults to 'en-US'.

      Parameter

      opts.numberingSystem - the numbering system to use

      Parameter

      opts.conversionAccuracy - the conversion system to use. Defaults to 'casual'.

    method get

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

      Parameter unit

      a unit such as 'minute' or 'day'

      Example 1

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

      Example 2

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

      Example 3

      Duration.fromObject({years: 2, days: 3}).get('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. Defaults to null.

    method isDuration

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

      Parameter o

    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: DurationLike) => Duration;
    • Make this Duration shorter by the specified amount. Return a newly-constructed Duration.

      Parameter duration

      The amount to subtract. Either a Luxon Duration, a number of milliseconds, the object argument to Duration.fromObject()

    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: DurationLike) => Duration;
    • Make this Duration longer by the specified amount. Return a newly-constructed Duration.

      Parameter duration

      The amount to add. Either a Luxon Duration, a number of milliseconds, the object argument to Duration.fromObject()

    method reconfigure

    reconfigure: (opts?: DurationOptions) => Duration;
    • "Set" the locale and/or numberingSystem. Returns a newly-constructed Duration.

      Example 1

      dur.reconfigure({ locale: 'en-GB' })

    method set

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

      Parameter values

      a mapping of units to numbers

      Example 1

      dur.set({ years: 2017 })

      Example 2

      dur.set({ hours: 8, minutes: 30 })

    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: (fmt: string, opts?: { floor?: boolean | undefined }) => 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 Durations's conversion accuracy setting.

      Parameter fmt

      the format string

      Parameter opts

      options

      Parameter

      opts.floor - floor numerical values. Defaults to true.

      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 toHuman

    toHuman: (opts?: ToHumanDurationOptions) => string;
    • Returns a string representation of a Duration with all units included To modify its behavior use the listStyle and any Intl.NumberFormat option, though unitDisplay is especially relevant. See Intl.NumberFormat.

      Parameter opts

      On option object to override the formatting. Accepts the same keys as the options parameter of the native Int.NumberFormat constructor, as well as listStyle.

      Example 1

      var dur = Duration.fromObject({ days: 1, hours: 5, minutes: 6 })
      dur.toHuman() //=> '1 day, 5 hours, 6 minutes'
      dur.toHuman({ listStyle: "long" }) //=> '1 day, 5 hours, and 6 minutes'
      dur.toHuman({ unitDisplay: "short" }) //=> '1 day, 5 hr, 6 min'

    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: (opts?: ToISOTimeDurationOptions) => string;
    • Returns an ISO 8601-compliant string representation of this Duration, formatted as a time of day.

      Parameter opts

      options

      Parameter

      opts.suppressMilliseconds - exclude milliseconds from the format if they're 0. Defaults to false.

      Parameter

      opts.suppressSeconds - exclude seconds from the format if they're 0. Defaults to false.

      Parameter

      opts.includePrefix - include the T prefix. Defaults to false.

      Parameter

      opts.format - choose between the basic and extended format. Defaults to 'extended'.

      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.

    method toMillis

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

    method toObject

    toObject: () => DurationObjectUnits;
    • Returns a JavaScript object with this Duration's values.

      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

    class FixedOffsetZone

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

    property utcInstance

    static readonly 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(name: string);

      method create

      static create: (name: 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

      readonly end: DateTime;
      • Returns the end of the Interval

      property invalidExplanation

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

      property invalidReason

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

      property isValid

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

      property start

      readonly 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.

        Parameter other

      method abutsStart

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

        Parameter other

      method after

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

        Parameter start

        Parameter duration

        the length of the Interval.

      method before

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

        Parameter end

        Parameter duration

        the length of the Interval.

      method contains

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

        Parameter 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 Interval#length this counts sections of the calendar, not periods of time, e.g. specifying 'day' asks 'what dates are included in this interval?', not 'how many days long is this interval?'

        Parameter unit

        the unit of time to count. Defaults to 'milliseconds'.

      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.

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

        Parameter other

      method equals

      equals: (other: Interval) => boolean;
      • Return whether this Interval has the same start and end as the specified Interval.

        Parameter other

      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.

        Parameter start

        Parameter end

      method fromISO

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

        Parameter text

        the ISO string to parse

        Parameter opts

        options to pass DateTime.fromISO and optionally Duration.fromISO

        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.

        Parameter other

      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. Defaults to null.

      method isAfter

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

        Parameter dateTime

      method isBefore

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

        Parameter dateTime

      method isEmpty

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

      method isInterval

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

        Parameter o

      method length

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

        Parameter unit

        the unit (such as 'hours' or 'days') 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

        Parameter mapFn

        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.

        Parameter intervals

      method overlaps

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

        Parameter other

      method set

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

        Parameter values

        the values to set

        Parameter

        values.start - the starting DateTime

        Parameter

        values.end - the ending DateTime

      method splitAt

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

        Parameter dateTimes

        the unit of time to count.

      method splitBy

      splitBy: (duration: DurationLike) => 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[],
      opts?: DiffOptions
      ) => Duration;
      • Return a Duration representing the time spanned by this interval.

        Parameter unit

        the unit or units (such as 'hours' or 'days') to include in the duration. Defaults to ['milliseconds'].

        Parameter opts

        options that affect the creation of the Duration

        Parameter

        opts.conversionAccuracy - the conversion system to use. Defaults to 'casual'.

        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,
      opts?: { separator?: string | undefined }
      ) => 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 opts

        options

        Parameter

        opts.separator - a separator to place between the start and end representations. Defaults to ' - '.

      method toISO

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

        Parameter opts

        The same options as DateTime#toISO

        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: (opts?: ToISOTimeOptions) => string;
      • Returns an ISO 8601-compliant string representation of time of this Interval. The date components are ignored.

        Parameter opts

        The same options as DateTime.toISO

        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.

        Parameter other

      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.

        Parameter intervals

      class InvalidZone

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

      class Settings

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

      property defaultLocale

      static defaultLocale: string;
      • Get the default locale to create DateTimes with. Does not affect existing instances.

      property defaultNumberingSystem

      static defaultNumberingSystem: string;
      • Get the default numbering system to create DateTimes with. Does not affect existing instances.

      property defaultOutputCalendar

      static defaultOutputCalendar: string;
      • Get the default output calendar to create DateTimes with. Does not affect existing instances.

      property defaultZone

      static defaultZone: string | Zone;
      • The default time zone object currently used to create DateTimes. Does not affect existing instances. The default value is the system's time zone (the one set on the machine that runs this code). Getting this property always returns a Zone object.

      property now

      static now: () => number;
      • Get the callback for returning the current timestamp.

      property throwOnInvalid

      static throwOnInvalid: boolean;
      • Get whether Luxon will throw when it encounters invalid DateTimes, Durations, or Intervals

      method resetCaches

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

      class SystemZone

      class SystemZone extends Zone {}
      • Represents the system zone for this JavaScript environment.

      property instance

      static readonly instance: SystemZone;
      • Get a singleton instance of the system zone

      class Zone

      abstract class Zone {}

        property isUniversal

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

        property isValid

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

        property name

        readonly name: string;
        • The name of this zone.

        property type

        readonly type: string;
        • The type of zone

        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 DateObjectUnits

        interface DateObjectUnits {}

          property day

          day?: number | undefined;

            property hour

            hour?: number | undefined;

              property millisecond

              millisecond?: number | undefined;

                property minute

                minute?: number | undefined;

                  property month

                  month?: number | undefined;

                    property ordinal

                    ordinal?: number | undefined;

                      property second

                      second?: number | undefined;

                        property weekday

                        weekday?: number | undefined;

                          property weekNumber

                          weekNumber?: number | undefined;

                            property weekYear

                            weekYear?: number | undefined;

                              property year

                              year?: number | undefined;

                                interface DateTimeOptions

                                interface DateTimeOptions extends LocaleOptions {}

                                  property setZone

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

                                  property zone

                                  zone?: string | Zone | undefined;
                                  • 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 | undefined;

                                      interface DurationLikeObject

                                      interface DurationLikeObject extends DurationObjectUnits {}

                                        property day

                                        day?: number | undefined;

                                          property hour

                                          hour?: number | undefined;

                                            property millisecond

                                            millisecond?: number | undefined;

                                              property minute

                                              minute?: number | undefined;

                                                property month

                                                month?: number | undefined;

                                                  property quarter

                                                  quarter?: number | undefined;

                                                    property second

                                                    second?: number | undefined;

                                                      property week

                                                      week?: number | undefined;

                                                        property year

                                                        year?: number | undefined;

                                                          interface DurationObjectUnits

                                                          interface DurationObjectUnits {}

                                                            property days

                                                            days?: number | undefined;

                                                              property hours

                                                              hours?: number | undefined;

                                                                property milliseconds

                                                                milliseconds?: number | undefined;

                                                                  property minutes

                                                                  minutes?: number | undefined;

                                                                    property months

                                                                    months?: number | undefined;

                                                                      property quarters

                                                                      quarters?: number | undefined;

                                                                        property seconds

                                                                        seconds?: number | undefined;

                                                                          property weeks

                                                                          weeks?: number | undefined;

                                                                            property years

                                                                            years?: number | undefined;

                                                                              interface DurationOptions

                                                                              interface DurationOptions {}

                                                                                property conversionAccuracy

                                                                                conversionAccuracy?: ConversionAccuracy | undefined;

                                                                                  property locale

                                                                                  locale?: string | undefined;

                                                                                    property numberingSystem

                                                                                    numberingSystem?: NumberingSystem | undefined;

                                                                                      interface ExplainedFormat

                                                                                      interface ExplainedFormat {}

                                                                                        property input

                                                                                        input: string;

                                                                                          property invalidReason

                                                                                          invalidReason?: string | undefined;

                                                                                            property matches

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

                                                                                              property rawMatches

                                                                                              rawMatches?: RegExpMatchArray | null | undefined;

                                                                                                property regex

                                                                                                regex?: RegExp | undefined;

                                                                                                  property result

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

                                                                                                    property tokens

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

                                                                                                      property zone

                                                                                                      zone?: Zone | null | undefined;

                                                                                                        interface Features

                                                                                                        interface Features {}
                                                                                                        • The set of available features in this environment. Some features of Luxon are not available in all environments.

                                                                                                        property relative

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

                                                                                                        interface InfoCalendarOptions

                                                                                                        interface InfoCalendarOptions extends InfoUnitOptions {}

                                                                                                          property outputCalendar

                                                                                                          outputCalendar?: CalendarSystem | undefined;

                                                                                                            interface InfoOptions

                                                                                                            interface InfoOptions {}

                                                                                                              property locale

                                                                                                              locale?: string | undefined;

                                                                                                                interface InfoUnitOptions

                                                                                                                interface InfoUnitOptions extends InfoOptions {}

                                                                                                                  property numberingSystem

                                                                                                                  numberingSystem?: NumberingSystem | undefined;

                                                                                                                    interface IntervalObject

                                                                                                                    interface IntervalObject {}

                                                                                                                      property end

                                                                                                                      end?: DateTime | undefined;

                                                                                                                        property start

                                                                                                                        start?: DateTime | undefined;

                                                                                                                          interface LocaleOptions

                                                                                                                          interface LocaleOptions {}

                                                                                                                            property locale

                                                                                                                            locale?: string | undefined;
                                                                                                                            • system's locale

                                                                                                                            property numberingSystem

                                                                                                                            numberingSystem?: NumberingSystem | undefined;

                                                                                                                              property outputCalendar

                                                                                                                              outputCalendar?: CalendarSystem | undefined;

                                                                                                                                interface ToHumanDurationOptions

                                                                                                                                interface ToHumanDurationOptions extends Intl.NumberFormatOptions {}

                                                                                                                                  property listStyle

                                                                                                                                  listStyle?: 'long' | 'short' | 'narrow' | undefined;

                                                                                                                                    interface ToISODateOptions

                                                                                                                                    interface ToISODateOptions {}

                                                                                                                                      property format

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

                                                                                                                                      interface ToISOTimeDurationOptions

                                                                                                                                      interface ToISOTimeDurationOptions {}

                                                                                                                                        property format

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

                                                                                                                                        property includePrefix

                                                                                                                                        includePrefix?: boolean | undefined;
                                                                                                                                        • Include the T prefix false

                                                                                                                                        property suppressMilliseconds

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

                                                                                                                                        property suppressSeconds

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

                                                                                                                                        interface ToISOTimeOptions

                                                                                                                                        interface ToISOTimeOptions extends ToISOTimeDurationOptions {}

                                                                                                                                          property includeOffset

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

                                                                                                                                          interface ToObjectOutput

                                                                                                                                          interface ToObjectOutput extends DateTimeJSOptions {}

                                                                                                                                            property day

                                                                                                                                            day: number;

                                                                                                                                              property hour

                                                                                                                                              hour: number;

                                                                                                                                                property millisecond

                                                                                                                                                millisecond: number;

                                                                                                                                                  property minute

                                                                                                                                                  minute: number;

                                                                                                                                                    property month

                                                                                                                                                    month: number;

                                                                                                                                                      property second

                                                                                                                                                      second: number;

                                                                                                                                                        property year

                                                                                                                                                        year: number;

                                                                                                                                                          interface ToRelativeCalendarOptions

                                                                                                                                                          interface ToRelativeCalendarOptions {}

                                                                                                                                                            property base

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

                                                                                                                                                            property locale

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

                                                                                                                                                            property numberingSystem

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

                                                                                                                                                            property unit

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

                                                                                                                                                            interface ToRelativeOptions

                                                                                                                                                            interface ToRelativeOptions extends Omit<ToRelativeCalendarOptions, 'unit'> {}

                                                                                                                                                              property padding

                                                                                                                                                              padding?: number | undefined;
                                                                                                                                                              • 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 | undefined;
                                                                                                                                                              • true

                                                                                                                                                              property style

                                                                                                                                                              style?: StringUnitLength | undefined;
                                                                                                                                                              • long

                                                                                                                                                              property unit

                                                                                                                                                              unit?: ToRelativeUnit | ToRelativeUnit[] | undefined;
                                                                                                                                                              • A single unit or an array of units. If an array is supplied, the method will pick the best one to use from the array. If omitted, the method will pick the unit from a default set.

                                                                                                                                                              interface ToSQLOptions

                                                                                                                                                              interface ToSQLOptions {}

                                                                                                                                                                property includeOffset

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

                                                                                                                                                                property includeOffsetSpace

                                                                                                                                                                includeOffsetSpace?: boolean;
                                                                                                                                                                • include the space between the time and the offset, such as '05:15:16.345 -04:00' true

                                                                                                                                                                property includeZone

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

                                                                                                                                                                interface ZoneOffsetOptions

                                                                                                                                                                interface ZoneOffsetOptions {}

                                                                                                                                                                  property format

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

                                                                                                                                                                  property locale

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

                                                                                                                                                                  interface ZoneOptions

                                                                                                                                                                  interface ZoneOptions {}

                                                                                                                                                                    property keepCalendarTime

                                                                                                                                                                    keepCalendarTime?: boolean | undefined;
                                                                                                                                                                    • Deprecated

                                                                                                                                                                      since 0.2.12. Use keepLocalTime instead

                                                                                                                                                                    property keepLocalTime

                                                                                                                                                                    keepLocalTime?: boolean | undefined;
                                                                                                                                                                    • 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 | DateObjectUnits | Date;

                                                                                                                                                                          type DateTimeFormatOptions

                                                                                                                                                                          type DateTimeFormatOptions = Intl.DateTimeFormatOptions;

                                                                                                                                                                            type DateTimeFormatPreset

                                                                                                                                                                            type DateTimeFormatPreset = Intl.DateTimeFormatOptions;
                                                                                                                                                                            • Deprecated

                                                                                                                                                                              Use Intl.DateTimeFormatOptions instead.

                                                                                                                                                                            type DateTimeFormatPresetValue

                                                                                                                                                                            type DateTimeFormatPresetValue = 'numeric' | 'short' | 'long';
                                                                                                                                                                            • Deprecated

                                                                                                                                                                              You should use Intl.DateTimeFormatOptions' fields and values instead.

                                                                                                                                                                            type DateTimeJSOptions

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

                                                                                                                                                                              type DateTimeUnit

                                                                                                                                                                              type DateTimeUnit =
                                                                                                                                                                              | 'year'
                                                                                                                                                                              | 'quarter'
                                                                                                                                                                              | 'month'
                                                                                                                                                                              | 'week'
                                                                                                                                                                              | 'day'
                                                                                                                                                                              | 'hour'
                                                                                                                                                                              | 'minute'
                                                                                                                                                                              | 'second'
                                                                                                                                                                              | 'millisecond';

                                                                                                                                                                                type DayNumbers

                                                                                                                                                                                type DayNumbers =
                                                                                                                                                                                | 1
                                                                                                                                                                                | 2
                                                                                                                                                                                | 3
                                                                                                                                                                                | 4
                                                                                                                                                                                | 5
                                                                                                                                                                                | 6
                                                                                                                                                                                | 7
                                                                                                                                                                                | 8
                                                                                                                                                                                | 9
                                                                                                                                                                                | 10
                                                                                                                                                                                | 11
                                                                                                                                                                                | 12
                                                                                                                                                                                | 13
                                                                                                                                                                                | 14
                                                                                                                                                                                | 15
                                                                                                                                                                                | 16
                                                                                                                                                                                | 17
                                                                                                                                                                                | 18
                                                                                                                                                                                | 19
                                                                                                                                                                                | 20
                                                                                                                                                                                | 21
                                                                                                                                                                                | 22
                                                                                                                                                                                | 23
                                                                                                                                                                                | 24
                                                                                                                                                                                | 25
                                                                                                                                                                                | 26
                                                                                                                                                                                | 27
                                                                                                                                                                                | 28
                                                                                                                                                                                | 29
                                                                                                                                                                                | 30
                                                                                                                                                                                | 31;

                                                                                                                                                                                  type DurationInput

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

                                                                                                                                                                                    Deprecated

                                                                                                                                                                                    Use DurationLike instead.

                                                                                                                                                                                  type DurationLike

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

                                                                                                                                                                                  type DurationUnit

                                                                                                                                                                                  type DurationUnit = keyof DurationLikeObject;

                                                                                                                                                                                    type DurationUnits

                                                                                                                                                                                    type DurationUnits = DurationUnit | DurationUnit[];

                                                                                                                                                                                      type EraLength

                                                                                                                                                                                      type EraLength = StringUnitLength;
                                                                                                                                                                                      • Deprecated

                                                                                                                                                                                      type HourCycle

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

                                                                                                                                                                                        type HourNumbers

                                                                                                                                                                                        type HourNumbers =
                                                                                                                                                                                        | 0
                                                                                                                                                                                        | 1
                                                                                                                                                                                        | 2
                                                                                                                                                                                        | 3
                                                                                                                                                                                        | 4
                                                                                                                                                                                        | 5
                                                                                                                                                                                        | 6
                                                                                                                                                                                        | 7
                                                                                                                                                                                        | 8
                                                                                                                                                                                        | 9
                                                                                                                                                                                        | 10
                                                                                                                                                                                        | 11
                                                                                                                                                                                        | 12
                                                                                                                                                                                        | 13
                                                                                                                                                                                        | 14
                                                                                                                                                                                        | 15
                                                                                                                                                                                        | 16
                                                                                                                                                                                        | 17
                                                                                                                                                                                        | 18
                                                                                                                                                                                        | 19
                                                                                                                                                                                        | 20
                                                                                                                                                                                        | 21
                                                                                                                                                                                        | 22
                                                                                                                                                                                        | 23;

                                                                                                                                                                                          type ISOTimeOptions

                                                                                                                                                                                          type ISOTimeOptions = ToISOTimeOptions;
                                                                                                                                                                                          • Deprecated

                                                                                                                                                                                            alias for backwards compatibility

                                                                                                                                                                                          type MinuteNumbers

                                                                                                                                                                                          type MinuteNumbers = SecondNumbers;

                                                                                                                                                                                            type MonthNumbers

                                                                                                                                                                                            type MonthNumbers = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;

                                                                                                                                                                                              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 PossibleDaysInMonth

                                                                                                                                                                                                  type PossibleDaysInMonth = 28 | 29 | 30 | 31;

                                                                                                                                                                                                    type PossibleDaysInYear

                                                                                                                                                                                                    type PossibleDaysInYear = 365 | 366;

                                                                                                                                                                                                      type PossibleWeeksInYear

                                                                                                                                                                                                      type PossibleWeeksInYear = 52 | 53;

                                                                                                                                                                                                        type QuarterNumbers

                                                                                                                                                                                                        type QuarterNumbers = 1 | 2 | 3 | 4;

                                                                                                                                                                                                          type ResolvedLocaleOptions

                                                                                                                                                                                                          type ResolvedLocaleOptions = Required<LocaleOptions>;

                                                                                                                                                                                                            type SecondNumbers

                                                                                                                                                                                                            type SecondNumbers =
                                                                                                                                                                                                            | 0
                                                                                                                                                                                                            | 1
                                                                                                                                                                                                            | 2
                                                                                                                                                                                                            | 3
                                                                                                                                                                                                            | 4
                                                                                                                                                                                                            | 5
                                                                                                                                                                                                            | 6
                                                                                                                                                                                                            | 7
                                                                                                                                                                                                            | 8
                                                                                                                                                                                                            | 9
                                                                                                                                                                                                            | 10
                                                                                                                                                                                                            | 11
                                                                                                                                                                                                            | 12
                                                                                                                                                                                                            | 13
                                                                                                                                                                                                            | 14
                                                                                                                                                                                                            | 15
                                                                                                                                                                                                            | 16
                                                                                                                                                                                                            | 17
                                                                                                                                                                                                            | 18
                                                                                                                                                                                                            | 19
                                                                                                                                                                                                            | 20
                                                                                                                                                                                                            | 21
                                                                                                                                                                                                            | 22
                                                                                                                                                                                                            | 23
                                                                                                                                                                                                            | 24
                                                                                                                                                                                                            | 25
                                                                                                                                                                                                            | 26
                                                                                                                                                                                                            | 27
                                                                                                                                                                                                            | 28
                                                                                                                                                                                                            | 29
                                                                                                                                                                                                            | 30
                                                                                                                                                                                                            | 31
                                                                                                                                                                                                            | 32
                                                                                                                                                                                                            | 33
                                                                                                                                                                                                            | 34
                                                                                                                                                                                                            | 35
                                                                                                                                                                                                            | 36
                                                                                                                                                                                                            | 37
                                                                                                                                                                                                            | 38
                                                                                                                                                                                                            | 39
                                                                                                                                                                                                            | 40
                                                                                                                                                                                                            | 41
                                                                                                                                                                                                            | 42
                                                                                                                                                                                                            | 43
                                                                                                                                                                                                            | 44
                                                                                                                                                                                                            | 45
                                                                                                                                                                                                            | 46
                                                                                                                                                                                                            | 47
                                                                                                                                                                                                            | 48
                                                                                                                                                                                                            | 49
                                                                                                                                                                                                            | 50
                                                                                                                                                                                                            | 51
                                                                                                                                                                                                            | 52
                                                                                                                                                                                                            | 53
                                                                                                                                                                                                            | 54
                                                                                                                                                                                                            | 55
                                                                                                                                                                                                            | 56
                                                                                                                                                                                                            | 57
                                                                                                                                                                                                            | 58
                                                                                                                                                                                                            | 59;

                                                                                                                                                                                                              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 WeekdayNumbers

                                                                                                                                                                                                                      type WeekdayNumbers = 1 | 2 | 3 | 4 | 5 | 6 | 7;

                                                                                                                                                                                                                        type WeekNumbers

                                                                                                                                                                                                                        type WeekNumbers =
                                                                                                                                                                                                                        | 1
                                                                                                                                                                                                                        | 2
                                                                                                                                                                                                                        | 3
                                                                                                                                                                                                                        | 4
                                                                                                                                                                                                                        | 5
                                                                                                                                                                                                                        | 6
                                                                                                                                                                                                                        | 7
                                                                                                                                                                                                                        | 8
                                                                                                                                                                                                                        | 9
                                                                                                                                                                                                                        | 10
                                                                                                                                                                                                                        | 11
                                                                                                                                                                                                                        | 12
                                                                                                                                                                                                                        | 13
                                                                                                                                                                                                                        | 14
                                                                                                                                                                                                                        | 15
                                                                                                                                                                                                                        | 16
                                                                                                                                                                                                                        | 17
                                                                                                                                                                                                                        | 18
                                                                                                                                                                                                                        | 19
                                                                                                                                                                                                                        | 20
                                                                                                                                                                                                                        | 21
                                                                                                                                                                                                                        | 22
                                                                                                                                                                                                                        | 23
                                                                                                                                                                                                                        | 24
                                                                                                                                                                                                                        | 25
                                                                                                                                                                                                                        | 26
                                                                                                                                                                                                                        | 27
                                                                                                                                                                                                                        | 28
                                                                                                                                                                                                                        | 29
                                                                                                                                                                                                                        | 30
                                                                                                                                                                                                                        | 31
                                                                                                                                                                                                                        | 32
                                                                                                                                                                                                                        | 33
                                                                                                                                                                                                                        | 34
                                                                                                                                                                                                                        | 35
                                                                                                                                                                                                                        | 36
                                                                                                                                                                                                                        | 37
                                                                                                                                                                                                                        | 38
                                                                                                                                                                                                                        | 39
                                                                                                                                                                                                                        | 40
                                                                                                                                                                                                                        | 41
                                                                                                                                                                                                                        | 42
                                                                                                                                                                                                                        | 43
                                                                                                                                                                                                                        | 44
                                                                                                                                                                                                                        | 45
                                                                                                                                                                                                                        | 46
                                                                                                                                                                                                                        | 47
                                                                                                                                                                                                                        | 48
                                                                                                                                                                                                                        | 49
                                                                                                                                                                                                                        | 50
                                                                                                                                                                                                                        | 51
                                                                                                                                                                                                                        | 52
                                                                                                                                                                                                                        | 53;

                                                                                                                                                                                                                          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". Defaults to 'short'.

                                                                                                                                                                                                                            Parameter opts

                                                                                                                                                                                                                            options

                                                                                                                                                                                                                            Parameter

                                                                                                                                                                                                                            opts.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: * relative: whether this environment supports relative time formatting

                                                                                                                                                                                                                            Example 1

                                                                                                                                                                                                                            Info.features() //=> { intl: true, intlTokens: false, zones: true, relative: false }

                                                                                                                                                                                                                          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. Defaults to 'local'.

                                                                                                                                                                                                                          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 opts

                                                                                                                                                                                                                            options

                                                                                                                                                                                                                            Parameter

                                                                                                                                                                                                                            opts.locale - the locale code

                                                                                                                                                                                                                            Example 1

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

                                                                                                                                                                                                                            Example 2

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

                                                                                                                                                                                                                          function months

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

                                                                                                                                                                                                                            Parameter length

                                                                                                                                                                                                                            the length of the month representation, such as "numeric", "2-digit", "narrow", "short", "long". Defaults to 'long'.

                                                                                                                                                                                                                            Parameter opts

                                                                                                                                                                                                                            options

                                                                                                                                                                                                                            Parameter

                                                                                                                                                                                                                            opts.locale - the locale code

                                                                                                                                                                                                                            Parameter

                                                                                                                                                                                                                            opts.numberingSystem - the numbering system. Defaults to null.

                                                                                                                                                                                                                            Parameter

                                                                                                                                                                                                                            opts.locObj - an existing locale object to use. Defaults to null.

                                                                                                                                                                                                                            Parameter

                                                                                                                                                                                                                            opts.outputCalendar - the calendar. Defaults to 'gregory'.

                                                                                                                                                                                                                            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 Info#months

                                                                                                                                                                                                                            Parameter length

                                                                                                                                                                                                                            the length of the month representation, such as "numeric", "2-digit", "narrow", "short", "long". Defaults to 'long'.

                                                                                                                                                                                                                            Parameter opts

                                                                                                                                                                                                                            options

                                                                                                                                                                                                                            Parameter

                                                                                                                                                                                                                            opts.locale - the locale code

                                                                                                                                                                                                                            Parameter

                                                                                                                                                                                                                            opts.numberingSystem - the numbering system. Defaults to null.

                                                                                                                                                                                                                            Parameter

                                                                                                                                                                                                                            opts.locObj - an existing locale object to use. Defaults to null.

                                                                                                                                                                                                                            Parameter

                                                                                                                                                                                                                            opts.outputCalendar - the calendar. Defaults to 'gregory'.

                                                                                                                                                                                                                          function normalizeZone

                                                                                                                                                                                                                          normalizeZone: (input?: string | Zone | number) => 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, such as "narrow", "short", "long". Defaults to 'long'.

                                                                                                                                                                                                                            Parameter opts

                                                                                                                                                                                                                            options

                                                                                                                                                                                                                            Parameter

                                                                                                                                                                                                                            opts.locale - the locale code

                                                                                                                                                                                                                            Parameter

                                                                                                                                                                                                                            opts.numberingSystem - the numbering system. Defaults to null.

                                                                                                                                                                                                                            Parameter

                                                                                                                                                                                                                            opts.locObj - an existing locale object to use. Defaults to null.

                                                                                                                                                                                                                            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 Info#weekdays

                                                                                                                                                                                                                            Parameter length

                                                                                                                                                                                                                            the length of the month representation, such as "narrow", "short", "long". Defaults to 'long'.

                                                                                                                                                                                                                            Parameter opts

                                                                                                                                                                                                                            options

                                                                                                                                                                                                                            Parameter

                                                                                                                                                                                                                            opts.locale - the locale code. Defaults to null.

                                                                                                                                                                                                                            Parameter

                                                                                                                                                                                                                            opts.numberingSystem - the numbering system. Defaults to null.

                                                                                                                                                                                                                            Parameter

                                                                                                                                                                                                                            opts.locObj - an existing locale object to use. Defaults to null.

                                                                                                                                                                                                                          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>