Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
(Info.eras("long", { locale: "de-DE" }): Array);
// $ExpectError
(Info.eras("long", { foo: "bar" }): Array);
(Info.features().intl: boolean);
(Info.features().intlTokens: boolean);
(Info.features().timezones: boolean);
(Info.hasDST("America/Chicago"): boolean);
(Info.hasDST(new CustomZone()): boolean);
(Info.meridiems(): Array);
(Info.meridiems({ locale: "de-DE" }): Array);
(Info.months("long"): Array);
(Info.months("narrow", { locale: "de-DE" }): Array);
(Info.months("short", { numberingSystem: "arab" }): Array);
(Info.months("2-digit", {
numberingSystem: "latn",
outputCalendar: "buddhist"
}): Array);
// $ExpectError
(Info.months("long", { foo: "bar" }): Array);
(Info.monthsFormat("long"): Array);
(Info.monthsFormat("narrow", { locale: "de-DE" }): Array);
(Info.monthsFormat("short", { numberingSystem: "arab" }): Array);
(Info.monthsFormat("2-digit", {
numberingSystem: "latn",
outputCalendar: "buddhist"
}): Array);
// $ExpectError
(Info.eras("long", { locale: "de-DE" }): Array);
// $ExpectError
(Info.eras("long", { foo: "bar" }): Array);
(Info.features().intl: boolean);
(Info.features().intlTokens: boolean);
(Info.features().timezones: boolean);
(Info.hasDST("America/Chicago"): boolean);
(Info.hasDST(new CustomZone()): boolean);
(Info.meridiems(): Array);
(Info.meridiems({ locale: "de-DE" }): Array);
(Info.months("long"): Array);
(Info.months("narrow", { locale: "de-DE" }): Array);
(Info.months("short", { numberingSystem: "arab" }): Array);
(Info.months("2-digit", {
numberingSystem: "latn",
outputCalendar: "buddhist"
}): Array);
// $ExpectError
(Info.months("long", { foo: "bar" }): Array);
(Info.monthsFormat("long"): Array);
(Info.monthsFormat("narrow", { locale: "de-DE" }): Array);
(Info.monthsFormat("short", { numberingSystem: "arab" }): Array);
(Info.monthsFormat("2-digit", {
numberingSystem: "latn",
outputCalendar: "buddhist"
}): Array);
// $ExpectError
// $ExpectError
(Info.eras("long", { foo: "bar" }): Array);
(Info.features().intl: boolean);
(Info.features().intlTokens: boolean);
(Info.features().timezones: boolean);
(Info.hasDST("America/Chicago"): boolean);
(Info.hasDST(new CustomZone()): boolean);
(Info.meridiems(): Array);
(Info.meridiems({ locale: "de-DE" }): Array);
(Info.months("long"): Array);
(Info.months("narrow", { locale: "de-DE" }): Array);
(Info.months("short", { numberingSystem: "arab" }): Array);
(Info.months("2-digit", {
numberingSystem: "latn",
outputCalendar: "buddhist"
}): Array);
// $ExpectError
(Info.months("long", { foo: "bar" }): Array);
(Info.monthsFormat("long"): Array);
(Info.monthsFormat("narrow", { locale: "de-DE" }): Array);
(Info.monthsFormat("short", { numberingSystem: "arab" }): Array);
(Info.monthsFormat("2-digit", {
numberingSystem: "latn",
outputCalendar: "buddhist"
}): Array);
// $ExpectError
(Info.monthsFormat("long", { foo: "bar" }): Array);
(Info.eras("long"): Array);
(Info.eras("long", { locale: "de-DE" }): Array);
// $ExpectError
(Info.eras("long", { foo: "bar" }): Array);
(Info.features().intl: boolean);
(Info.features().intlTokens: boolean);
(Info.features().timezones: boolean);
(Info.hasDST("America/Chicago"): boolean);
(Info.hasDST(new CustomZone()): boolean);
(Info.meridiems(): Array);
(Info.meridiems({ locale: "de-DE" }): Array);
(Info.months("long"): Array);
(Info.months("narrow", { locale: "de-DE" }): Array);
(Info.months("short", { numberingSystem: "arab" }): Array);
(Info.months("2-digit", {
numberingSystem: "latn",
outputCalendar: "buddhist"
}): Array);
// $ExpectError
(Info.months("long", { foo: "bar" }): Array);
(Info.monthsFormat("long"): Array);
(Info.monthsFormat("narrow", { locale: "de-DE" }): Array);
(Info.monthsFormat("short", { numberingSystem: "arab" }): Array);
(Info.monthsFormat("2-digit", {
numberingSystem: "latn",
outputCalendar: "buddhist"
}): Array);
dt.locale; // $ExpectType string
DateTime.local().setLocale('fr').locale; // $ExpectType string
DateTime.local().reconfigure({ locale: 'fr' }).locale; // $ExpectType string
Settings.defaultLocale = 'fr';
DateTime.local().locale; // $ExpectType string
Settings.defaultLocale = DateTime.local().resolvedLocaleOpts().locale;
dt.setLocale('fr').toLocaleString(DateTime.DATE_FULL); // $ExpectType string
dt.toLocaleString({ locale: 'es', ...DateTime.DATE_FULL }); // $ExpectType string
dt.setLocale('fr').toFormat('MMMM dd, yyyy GG'); // $ExpectType string
DateTime.fromFormat('septembre 25, 2017 après Jésus-Christ', 'MMMM dd, yyyy GG', { locale: 'fr' });
Info.months('long', { locale: 'fr' }); // $ExpectType string[]
Info.weekdays('long', { locale: 'fr' }); // $ExpectType string[]
Info.eras('long', { locale: 'fr' }); // $ExpectType string[]
DateTime.local().reconfigure({ locale: 'it', numberingSystem: 'beng' });
Settings.defaultNumberingSystem = 'beng';
/* Time zones and offsets */
Info.features().zones; // $ExpectType boolean
const bogus = DateTime.local().setZone('America/Bogus');
bogus.isValid; // $ExpectType boolean
bogus.invalidReason; // $ExpectType string | null
bogus.invalidExplanation; // $ExpectType string | null
const local = DateTime.local(2017, 5, 15, 09, 10, 23);
local.zoneName; // $ExpectType string
i.toISO(); // $ExpectType string
i.toISODate(); // $ExpectType string
i.toISOTime(); // $ExpectType string
i.toString(); // $ExpectType string
i.toDuration('months'); // $ExpectType Duration
i.toDuration(); // $ExpectType Duration
if (Interval.isInterval(anything)) {
anything; // $ExpectType Interval
}
/* Info */
Info.months();
// $ExpectError
Info.months('2-digit', { outputCalendar: 'unknown' });
Info.weekdays('long');
// $ExpectError
Info.weekdays('2-digit');
Info.features().intl;
Info.features().intlTokens;
Info.features().zones;
/* Settings */
Settings.defaultLocale;
Settings.defaultLocale = 'en';
Settings.defaultZoneName = 'Europe/Paris';
Settings.throwOnInvalid = true;
Settings.now();
Settings.now = () => 0;
Settings.resetCaches();
(Info.eras("long", { foo: "bar" }): Array);
(Info.features().intl: boolean);
(Info.features().intlTokens: boolean);
(Info.features().timezones: boolean);
(Info.hasDST("America/Chicago"): boolean);
(Info.hasDST(new CustomZone()): boolean);
(Info.meridiems(): Array);
(Info.meridiems({ locale: "de-DE" }): Array);
(Info.months("long"): Array);
(Info.months("narrow", { locale: "de-DE" }): Array);
(Info.months("short", { numberingSystem: "arab" }): Array);
(Info.months("2-digit", {
numberingSystem: "latn",
outputCalendar: "buddhist"
}): Array);
// $ExpectError
(Info.months("long", { foo: "bar" }): Array);
(Info.monthsFormat("long"): Array);
(Info.monthsFormat("narrow", { locale: "de-DE" }): Array);
(Info.monthsFormat("short", { numberingSystem: "arab" }): Array);
(Info.monthsFormat("2-digit", {
numberingSystem: "latn",
outputCalendar: "buddhist"
}): Array);
// $ExpectError
(Info.monthsFormat("long", { foo: "bar" }): Array);
it('Info.months lists all the months', () => {
expect(Info.months('long', 'en')).toEqual(
['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
);
expect(Info.months('short', 'en')).toEqual(
['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
);
expect(Info.months('narrow', 'en')).toEqual(['J', 'F', 'M', 'A', 'M', 'J', 'J', 'A', 'S', 'O', 'N', 'D']);
expect(Info.months('numeric', 'en')).toEqual(['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12']);
});
export function months () {
return Info.months().map(month => capitalize(month))
}
export default function getMonths(type?: UnitLength): Months {
return Info.months(type, { locale: Core.locale() }) as Months;
}