Luxon Manual Reference
import Info from 'luxon/src/info.js'
public class | source

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.

Static Method Summary

Static Public Methods
public static

eras(length: string, opts: Object): [string]

Return an array of eras, such as ['BC', 'AD'].

public static

Return the set of available features in this environment.

public static

Return whether the specified zone contains a DST.

public static

Return whether the specified zone is a valid IANA specifier.

public static

meridiems(opts: Object): [string]

Return an array of meridiems.

public static

months(length: string, opts: Object): [string]

Return an array of standalone month names.

public static

monthsFormat(length: string, opts: Object): [string]

Return an array of format month names.

public static

weekdays(length: string, opts: Object): [string]

Return an array of standalone week names.

public static

weekdaysFormat(length: string, opts: Object): [string]

Return an array of format week names.

Static Public Methods

public static eras(length: string, opts: Object): [string] source

Return an array of eras, such as ['BC', 'AD']. The locale can be specified, but the calendar system is always Gregorian.

Params:

NameTypeAttributeDescription
length string
  • optional
  • default: 'short'

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

opts Object

options

opts.locale string
  • optional

the locale code

Return:

[string]

Example:

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

public static features(): Object source

Return the set of available features in this environment. Some features of Luxon are not available in all environments. For example, on older browsers, timezone support is not available. Use this function to figure out if that's the case. Keys:

  • zones: whether this environment supports IANA timezones
  • intlTokens: whether this environment supports internationalized token-based formatting/parsing
  • intl: whether this environment supports general internationalization

Return:

Object

Example:

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

public static hasDST(zone: string | Zone): boolean source

Return whether the specified zone contains a DST.

Params:

NameTypeAttributeDescription
zone string | Zone
  • optional
  • default: 'local'

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

Return:

boolean

public static isValidIANAZone(zone: string): boolean source

Return whether the specified zone is a valid IANA specifier.

Params:

NameTypeAttributeDescription
zone string

Zone to check

Return:

boolean

public static meridiems(opts: Object): [string] source

Return an array of meridiems.

Params:

NameTypeAttributeDescription
opts Object

options

opts.locale string
  • optional

the locale code

Return:

[string]

Example:

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

public static months(length: string, opts: Object): [string] source

Return an array of standalone month names.

Params:

NameTypeAttributeDescription
length string
  • optional
  • default: 'long'

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

opts Object

options

opts.locale string
  • optional

the locale code

opts.numberingSystem string
  • optional
  • default: null

the numbering system

opts.outputCalendar string
  • optional
  • default: 'gregory'

the calendar

Return:

[string]

Example:

Info.months()[0] //=> 'January'
Info.months('short')[0] //=> 'Jan'
Info.months('numeric')[0] //=> '1'
Info.months('short', { locale: 'fr-CA' } )[0] //=> 'janv.'
Info.months('numeric', { locale: 'ar' })[0] //=> '١'
Info.months('long', { outputCalendar: 'islamic' })[0] //=> 'Rabiʻ I'

See:

public static monthsFormat(length: string, opts: Object): [string] source

Return an array of format month names. Format months differ from standalone months in that they're meant to appear next to the day of the month. In some languages, that changes the string. See months

Params:

NameTypeAttributeDescription
length string
  • optional
  • default: 'long'

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

opts Object

options

opts.locale string
  • optional

the locale code

opts.numberingSystem string
  • optional
  • default: null

the numbering system

opts.outputCalendar string
  • optional
  • default: 'gregory'

the calendar

Return:

[string]

public static weekdays(length: string, opts: Object): [string] source

Return an array of standalone week names.

Params:

NameTypeAttributeDescription
length string
  • optional
  • default: 'long'

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

opts Object

options

opts.locale string
  • optional

the locale code

opts.numberingSystem string
  • optional
  • default: null

the numbering system

Return:

[string]

Example:

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

See:

public static weekdaysFormat(length: string, opts: Object): [string] source

Return an array of format week names. Format weekdays differ from standalone weekdays in that they're meant to appear next to more date information. In some languages, that changes the string. See weekdays

Params:

NameTypeAttributeDescription
length string
  • optional
  • default: 'long'

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

opts Object

options

opts.locale string
  • optional
  • default: null

the locale code

opts.numberingSystem string
  • optional
  • default: null

the numbering system

Return:

[string]