Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// $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.weekdays("long"): Array);
(Info.weekdays("narrow", { locale: "de-DE" }): Array);
(Info.weekdays("short", { numberingSystem: "arab" }): Array);
(Info.weekdays("long", {
numberingSystem: "latn",
outputCalendar: "buddhist"
}): Array);
// $ExpectError
(Info.weekdays("long", { foo: "bar" }): Array);
(Info.weekdaysFormat("long"): Array);
(Info.weekdaysFormat("narrow", { locale: "de-DE" }): Array);
(Info.weekdaysFormat("short", { numberingSystem: "arab" }): Array);
(Info.weekdaysFormat("long", {
numberingSystem: "latn",
outputCalendar: "buddhist"
}): Array);
// $ExpectError
(Info.weekdaysFormat("long", { foo: "bar" }): Array);
}): 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.weekdays("long"): Array);
(Info.weekdays("narrow", { locale: "de-DE" }): Array);
(Info.weekdays("short", { numberingSystem: "arab" }): Array);
(Info.weekdays("long", {
numberingSystem: "latn",
outputCalendar: "buddhist"
}): Array);
// $ExpectError
(Info.weekdays("long", { foo: "bar" }): Array);
(Info.weekdaysFormat("long"): Array);
(Info.weekdaysFormat("narrow", { locale: "de-DE" }): Array);
(Info.weekdaysFormat("short", { numberingSystem: "arab" }): Array);
(Info.weekdaysFormat("long", {
numberingSystem: "latn",
outputCalendar: "buddhist"
}): Array);
// $ExpectError
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.weekdays("long"): Array);
(Info.weekdays("narrow", { locale: "de-DE" }): Array);
(Info.weekdays("short", { numberingSystem: "arab" }): Array);
(Info.weekdays("long", {
numberingSystem: "latn",
outputCalendar: "buddhist"
}): Array);
// $ExpectError
(Info.weekdays("long", { foo: "bar" }): Array);
(Info.weekdaysFormat("long"): Array);
(Info.weekdaysFormat("narrow", { locale: "de-DE" }): Array);
(Info.weekdaysFormat("short", { numberingSystem: "arab" }): Array);
(Info.weekdaysFormat("long", {
numberingSystem: "latn",
outputCalendar: "buddhist"
}): Array);
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
local.toString(); // $ExpectType string
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.weekdays("long"): Array);
(Info.weekdays("narrow", { locale: "de-DE" }): Array);
(Info.weekdays("short", { numberingSystem: "arab" }): Array);
(Info.weekdays("long", {
numberingSystem: "latn",
outputCalendar: "buddhist"
}): Array);
// $ExpectError
(Info.weekdays("long", { foo: "bar" }): Array);
(Info.weekdaysFormat("long"): Array);
(Info.weekdaysFormat("narrow", { locale: "de-DE" }): Array);
(Info.weekdaysFormat("short", { numberingSystem: "arab" }): Array);
(Info.weekdaysFormat("long", {
numberingSystem: "latn",
outputCalendar: "buddhist"
}): Array);
}): 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.weekdays("long"): Array);
(Info.weekdays("narrow", { locale: "de-DE" }): Array);
(Info.weekdays("short", { numberingSystem: "arab" }): Array);
(Info.weekdays("long", {
numberingSystem: "latn",
outputCalendar: "buddhist"
}): Array);
// $ExpectError
(Info.weekdays("long", { foo: "bar" }): Array);
(Info.weekdaysFormat("long"): Array);
(Info.weekdaysFormat("narrow", { locale: "de-DE" }): Array);
(Info.weekdaysFormat("short", { numberingSystem: "arab" }): Array);
(Info.weekdaysFormat("long", {
numberingSystem: "latn",
outputCalendar: "buddhist"
}): Array);
// $ExpectError
it('Info.weekdays lists all the weekdays', () => {
expect(Info.weekdays('long', 'en')).toEqual(
['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']
);
expect(Info.weekdays('short', 'en')).toEqual(['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']);
expect(Info.weekdays('narrow', 'en')).toEqual(['S', 'M', 'T', 'W', 'T', 'F', 'S']);
expect(Info.weekdays('long', 'ru')).toEqual(
['воскресенье', 'понедельник', 'вторник', 'среда', 'четверг', 'пятница', 'суббота']
);
});
it('Info.weekdays lists all the weekdays', () => {
expect(Info.weekdays('long', 'en')).toEqual(
['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']
);
expect(Info.weekdays('short', 'en')).toEqual(['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']);
expect(Info.weekdays('narrow', 'en')).toEqual(['S', 'M', 'T', 'W', 'T', 'F', 'S']);
expect(Info.weekdays('long', 'ru')).toEqual(
['воскресенье', 'понедельник', 'вторник', 'среда', 'четверг', 'пятница', 'суббота']
);
});
export default function getWeekdays(
type?: StringUnitLength,
sundayFirst: boolean = false,
): Weekdays {
const days = [...Info.weekdays(type, { locale: Core.locale() })];
if (sundayFirst) {
const sunday = days.pop();
days.unshift(sunday!);
}
return days as Weekdays;
}
export function weekdays (weekStart) {
if (--weekStart < 0) {
weekStart = 6
}
let weekDays = Info.weekdays('short').map(weekday => capitalize(weekday))
weekDays = weekDays.concat(weekDays.splice(0, weekStart))
return weekDays
}