| 1 |
import { WeekdayNumbers } from "./datetime"; |
| 2 |
import { CalendarSystem, NumberingSystem, StringUnitLength, UnitLength } from "./misc"; |
| 3 |
import { Zone } from "./zone"; |
| 4 |
|
| 5 |
export interface InfoOptions { |
| 6 |
locale?: string | undefined; |
| 7 |
} |
| 8 |
|
| 9 |
export interface InfoUnitOptions extends InfoOptions { |
| 10 |
numberingSystem?: NumberingSystem | undefined; |
| 11 |
} |
| 12 |
|
| 13 |
/** @deprecated */ |
| 14 |
export type UnitOptions = InfoUnitOptions; |
| 15 |
|
| 16 |
export interface InfoCalendarOptions extends InfoUnitOptions { |
| 17 |
/** |
| 18 |
* @default gregory |
| 19 |
*/ |
| 20 |
outputCalendar?: CalendarSystem | undefined; |
| 21 |
} |
| 22 |
|
| 23 |
/** |
| 24 |
* The set of available features in this environment. Some features of Luxon are not available in all environments. |
| 25 |
*/ |
| 26 |
export interface Features { |
| 27 |
/** |
| 28 |
* Whether this environment supports relative time formatting |
| 29 |
*/ |
| 30 |
relative: boolean; |
| 31 |
|
| 32 |
/** |
| 33 |
* Whether this environment supports different weekdays for the start of the week based on the locale |
| 34 |
*/ |
| 35 |
localeWeek: boolean; |
| 36 |
} |
| 37 |
|
| 38 |
/** |
| 39 |
* 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 |
| 40 |
* supported locale, and for discovering which of Luxon features are available in the current environment. |
| 41 |
*/ |
| 42 |
export namespace Info { |
| 43 |
/** |
| 44 |
* Return whether the specified zone contains a DST. |
| 45 |
* |
| 46 |
* @param zone - Zone to check. Defaults to the environment's local zone. Defaults to 'local'. |
| 47 |
*/ |
| 48 |
function hasDST(zone?: string | Zone): boolean; |
| 49 |
|
| 50 |
/** |
| 51 |
* Return whether the specified zone is a valid IANA specifier. |
| 52 |
* |
| 53 |
* @param zone - Zone to check |
| 54 |
*/ |
| 55 |
function isValidIANAZone(zone: string): boolean; |
| 56 |
|
| 57 |
/** |
| 58 |
* Converts the input into a {@link Zone} instance. |
| 59 |
* |
| 60 |
* * If `input` is already a Zone instance, it is returned unchanged. |
| 61 |
* * If `input` is a string containing a valid time zone name, a Zone instance |
| 62 |
* with that name is returned. |
| 63 |
* * If `input` is a string that doesn't refer to a known time zone, a Zone |
| 64 |
* instance with {@link Zone.isValid} == false is returned. |
| 65 |
* * If `input is a number, a Zone instance with the specified fixed offset |
| 66 |
* in minutes is returned. |
| 67 |
* * If `input` is `null` or `undefined`, the default zone is returned. |
| 68 |
* |
| 69 |
* @param input - the value to be converted |
| 70 |
*/ |
| 71 |
function normalizeZone(input?: string | Zone | number): Zone; |
| 72 |
|
| 73 |
interface LocaleInput { |
| 74 |
/** |
| 75 |
* the locale code |
| 76 |
*/ |
| 77 |
locale?: string | null | undefined; |
| 78 |
/** |
| 79 |
* an existing locale object to use, instead of the locale code string |
| 80 |
*/ |
| 81 |
locObj?: object | null | undefined; |
| 82 |
} |
| 83 |
|
| 84 |
/** |
| 85 |
* Get the weekday on which the week starts, |
| 86 |
* according to the given locale. |
| 87 |
*/ |
| 88 |
function getStartOfWeek(input?: LocaleInput): WeekdayNumbers; |
| 89 |
|
| 90 |
/** |
| 91 |
* Get the minimum number of days necessary in a week before it is considered part of the next year, |
| 92 |
* according to the given locale. |
| 93 |
*/ |
| 94 |
function getMinimumDaysInFirstWeek(input?: LocaleInput): WeekdayNumbers; |
| 95 |
|
| 96 |
/** |
| 97 |
* Get the weekdays which are considered the weekend, |
| 98 |
* according to the given locale. |
| 99 |
*/ |
| 100 |
function getWeekendWeekdays(input?: LocaleInput): WeekdayNumbers[]; |
| 101 |
|
| 102 |
/** |
| 103 |
* Return an array of standalone month names. |
| 104 |
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat |
| 105 |
* |
| 106 |
* @param length - the length of the month representation. Defaults to 'long'. |
| 107 |
* @param opts - options |
| 108 |
* @param opts.locale - the locale code |
| 109 |
* @param opts.numberingSystem - the numbering system. |
| 110 |
* @param opts.locObj - an existing locale object to use. |
| 111 |
* @param opts.outputCalendar - the calendar. Defaults to 'gregory'. |
| 112 |
* |
| 113 |
* @example |
| 114 |
* Info.months()[0] //=> 'January' |
| 115 |
* @example |
| 116 |
* Info.months('short')[0] //=> 'Jan' |
| 117 |
* @example |
| 118 |
* Info.months('numeric')[0] //=> '1' |
| 119 |
* @example |
| 120 |
* Info.months('short', { locale: 'fr-CA' } )[0] //=> 'janv.' |
| 121 |
* @example |
| 122 |
* Info.months('numeric', { locale: 'ar' })[0] //=> '١' |
| 123 |
* @example |
| 124 |
* Info.months('long', { outputCalendar: 'islamic' })[0] //=> 'Rabiʻ I' |
| 125 |
*/ |
| 126 |
function months(length?: UnitLength, opts?: InfoCalendarOptions): string[]; |
| 127 |
|
| 128 |
/** |
| 129 |
* Return an array of format month names. |
| 130 |
* Format months differ from standalone months in that they are meant to appear next to the day of the month. |
| 131 |
* In some languages, that changes the string. |
| 132 |
* See {@link Info#months} |
| 133 |
* |
| 134 |
* @param length - the length of the month representation. Defaults to 'long'. |
| 135 |
* @param opts - options |
| 136 |
* @param opts.locale - the locale code |
| 137 |
* @param opts.numberingSystem - the numbering system. |
| 138 |
* @param opts.locObj - an existing locale object to use. |
| 139 |
* @param opts.outputCalendar - the calendar. Defaults to 'gregory'. |
| 140 |
*/ |
| 141 |
function monthsFormat(length?: UnitLength, opts?: InfoCalendarOptions): string[]; |
| 142 |
|
| 143 |
/** |
| 144 |
* Return an array of standalone week names. |
| 145 |
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat |
| 146 |
* |
| 147 |
* @param length - the length of the weekday representation. Defaults to 'long'. |
| 148 |
* @param opts - options |
| 149 |
* @param opts.locale - the locale code |
| 150 |
* @param opts.numberingSystem - the numbering system. |
| 151 |
* @param opts.locObj - an existing locale object to use. |
| 152 |
* |
| 153 |
* @example |
| 154 |
* Info.weekdays()[0] //=> 'Monday' |
| 155 |
* @example |
| 156 |
* Info.weekdays('short')[0] //=> 'Mon' |
| 157 |
* @example |
| 158 |
* Info.weekdays('short', { locale: 'fr-CA' })[0] //=> 'lun.' |
| 159 |
* @example |
| 160 |
* Info.weekdays('short', { locale: 'ar' })[0] //=> 'الاثنين' |
| 161 |
*/ |
| 162 |
function weekdays(length?: StringUnitLength, opts?: InfoUnitOptions): string[]; |
| 163 |
|
| 164 |
/** |
| 165 |
* Return an array of format week names. |
| 166 |
* Format weekdays differ from standalone weekdays in that they are meant to appear next to more date information. |
| 167 |
* In some languages, that changes the string. |
| 168 |
* See {@link Info#weekdays} |
| 169 |
* |
| 170 |
* @param length - the length of the month representation. Defaults to 'long'. |
| 171 |
* @param opts - options |
| 172 |
* @param opts.locale - the locale code. |
| 173 |
* @param opts.numberingSystem - the numbering system. |
| 174 |
* @param opts.locObj - an existing locale object to use. |
| 175 |
*/ |
| 176 |
function weekdaysFormat(length?: StringUnitLength, opts?: InfoUnitOptions): string[]; |
| 177 |
|
| 178 |
/** |
| 179 |
* Return an array of meridiems. |
| 180 |
* |
| 181 |
* @param opts - options |
| 182 |
* @param opts.locale - the locale code |
| 183 |
* |
| 184 |
* @example |
| 185 |
* Info.meridiems() //=> [ 'AM', 'PM' ] |
| 186 |
* @example |
| 187 |
* Info.meridiems({ locale: 'my' }) //=> [ 'နံနက်', 'ညနေ' ] |
| 188 |
*/ |
| 189 |
function meridiems(opts?: InfoOptions): string[]; |
| 190 |
|
| 191 |
/** |
| 192 |
* Return an array of eras, such as ['BC', 'AD']. The locale can be specified, but the calendar system is always Gregorian. |
| 193 |
* |
| 194 |
* @param length - the length of the era representation. Defaults to 'short'. |
| 195 |
* @param opts - options |
| 196 |
* @param opts.locale - the locale code |
| 197 |
* |
| 198 |
* @example |
| 199 |
* Info.eras() //=> [ 'BC', 'AD' ] |
| 200 |
* @example |
| 201 |
* Info.eras('long') //=> [ 'Before Christ', 'Anno Domini' ] |
| 202 |
* @example |
| 203 |
* Info.eras('long', { locale: 'fr' }) //=> [ 'avant Jésus-Christ', 'après Jésus-Christ' ] |
| 204 |
*/ |
| 205 |
function eras(length?: StringUnitLength, opts?: InfoOptions): string[]; |
| 206 |
|
| 207 |
/** |
| 208 |
* Return the set of available features in this environment. |
| 209 |
* Some features of Luxon are not available in all environments. |
| 210 |
* For example, on older browsers, timezone support is not available. |
| 211 |
* Use this function to figure out if that is the case. |
| 212 |
* |
| 213 |
* @example |
| 214 |
* Info.features() //=> { intl: true, intlTokens: false, zones: true, relative: false } |
| 215 |
*/ |
| 216 |
function features(): Features; |
| 217 |
} |