Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
protected setMomentLocaleData(locale: string) {
const momentLocaleData = moment.localeData(locale);
this.localeData = {
firstDayOfWeek: momentLocaleData.firstDayOfWeek(),
defaultFormat: momentLocaleData.longDateFormat('L'),
months: {
[TranslationWidth.SHORT]: momentLocaleData.monthsShort(),
[TranslationWidth.LONG]: momentLocaleData.months(),
},
days: {
[TranslationWidth.SHORT]: momentLocaleData.weekdaysShort(),
[TranslationWidth.LONG]: momentLocaleData.weekdays(),
},
};
}
}
public getMonthNameByIndex(month: number, style: TranslationWidth = TranslationWidth.SHORT): string {
return this.localeData.months[style][month];
}
public getMonthName(date: Moment, style: TranslationWidth = TranslationWidth.SHORT): string {
const month: number = this.getMonth(date);
return this.getMonthNameByIndex(month, style);
}