From 04071056eb2345d1488df074e19d06b5c86f8da0 Mon Sep 17 00:00:00 2001 From: Summer-Shen <1563407190@qq.com> Date: Fri, 12 Jan 2024 00:48:18 +0800 Subject: [PATCH] fix(date-picker): add dayjs updateLocale plugin to support correct week numbers --- js/date-picker/utils.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/js/date-picker/utils.ts b/js/date-picker/utils.ts index c8f2932ea8..e6300bc377 100644 --- a/js/date-picker/utils.ts +++ b/js/date-picker/utils.ts @@ -7,6 +7,7 @@ import localeData from 'dayjs/plugin/localeData'; import quarterOfYear from 'dayjs/plugin/quarterOfYear'; import advancedFormat from 'dayjs/plugin/advancedFormat'; import customParseFormat from 'dayjs/plugin/customParseFormat'; +import updateLocale from 'dayjs/plugin/updateLocale'; import chunk from 'lodash/chunk'; import { parseToDayjs } from './format'; @@ -17,6 +18,7 @@ dayjs.extend(quarterOfYear); dayjs.extend(advancedFormat); dayjs.extend(customParseFormat); dayjs.extend(dayJsIsBetween); +dayjs.extend(updateLocale); /** * 首字母大写 @@ -219,6 +221,9 @@ export function getWeeks( cancelRangeSelectLimit = false, }: OptionsType, ) { + // 更新 dayjs 已有的语言配置以获取正确的周数 + dayjs.updateLocale(dayjsLocale, { weekStart: firstDayOfWeek }); + const prependDay = getFirstDayOfMonth({ year, month }); const appendDay = getLastDayOfMonth({ year, month }); const maxDays = getDaysInMonth({ year, month });