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 |
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 |
isValidIANAZone(zone: string): boolean Return whether the specified zone is a valid IANA specifier. |
|
public static |
Return an array of meridiems. |
|
public static |
Return an array of standalone month names. |
|
public static |
monthsFormat(length: string, opts: Object): [string] Return an array of format month names. |
|
public static |
normalizeZone(input: string | Zone | number): Zone Converts the input into a Zone instance. |
|
public static |
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.
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 timezonesintlTokens
: whether this environment supports internationalized token-based formatting/parsingintl
: whether this environment supports general internationalizationrelative
: whether this environment supports relative time formatting
Example:
Info.features() //=> { intl: true, intlTokens: false, zones: true, relative: false }
public static hasDST(zone: string | Zone): boolean source
Return whether the specified zone contains a DST.
public static isValidIANAZone(zone: string): boolean source
Return whether the specified zone is a valid IANA specifier.
Params:
Name | Type | Attribute | Description |
zone | string | Zone to check |
public static meridiems(opts: Object): [string] source
Return an array of meridiems.
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:
Name | Type | Attribute | Description |
length | string |
|
the length of the month representation, such as "numeric", "2-digit", "narrow", "short", "long" |
opts | Object | options |
|
opts.locale | string |
|
the locale code |
opts.numberingSystem | string |
|
the numbering system |
opts.outputCalendar | string |
|
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'
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:
Name | Type | Attribute | Description |
length | string |
|
the length of the month representation, such as "numeric", "2-digit", "narrow", "short", "long" |
opts | Object | options |
|
opts.locale | string |
|
the locale code |
opts.numberingSystem | string |
|
the numbering system |
opts.outputCalendar | string |
|
the calendar |
Return:
[string] |
public static normalizeZone(input: string | Zone | number): Zone source
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
isnull
orundefined
, the default zone is returned.
public static weekdays(length: string, opts: Object): [string] source
Return an array of standalone week names.
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] //=> 'الاثنين'
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:
Name | Type | Attribute | Description |
length | string |
|
the length of the weekday representation, such as "narrow", "short", "long". |
opts | Object | options |
|
opts.locale | string |
|
the locale code |
opts.numberingSystem | string |
|
the numbering system |
Return:
[string] |