diff --git a/src/generate/luxon.ts b/src/generate/luxon.ts index cd1def454..2a31ecd67 100644 --- a/src/generate/luxon.ts +++ b/src/generate/luxon.ts @@ -54,7 +54,7 @@ const normalizeFormat = (format: string): string => */ const normalizeLocale = (locale: string): string => locale.replace(/_/g, '-'); -const generateConfig: GenerateConfig = { +const getGenerateConfig = (useLocaleWeeks?: boolean): GenerateConfig => ({ // get getNow: () => DateTime.local(), getFixedDate: (string) => DateTime.fromFormat(string, 'yyyy-MM-dd'), @@ -85,9 +85,11 @@ const generateConfig: GenerateConfig = { isValidate: (date) => date.isValid, locale: { - getWeekFirstDate: (locale, date) => date.setLocale(normalizeLocale(locale)).startOf('week'), + getWeekFirstDate: (locale, date) => + date.setLocale(normalizeLocale(locale)).startOf('week', { useLocaleWeeks }), getWeekFirstDay: (locale) => - DateTime.local().setLocale(normalizeLocale(locale)).startOf('week').weekday, + DateTime.local().setLocale(normalizeLocale(locale)).startOf('week', { useLocaleWeeks }) + .weekday, getWeek: (locale, date) => date.setLocale(normalizeLocale(locale)).weekNumber, getShortWeekDays: (locale) => { const weekdays = Info.weekdays(weekDayFormatMap[locale] || 'short', { @@ -126,6 +128,8 @@ const generateConfig: GenerateConfig = { return null; }, }, -}; +}); +const generateConfig = getGenerateConfig(); +export const generateConfigWithLocale = getGenerateConfig(true); export default generateConfig;