Skip to content

Commit

Permalink
fix(date-picker): add dayjs updateLocale plugin to support correct we…
Browse files Browse the repository at this point in the history
…ek numbers
  • Loading branch information
Summer-Shen committed Jan 11, 2024
1 parent 1968767 commit 0407105
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions js/date-picker/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -17,6 +18,7 @@ dayjs.extend(quarterOfYear);
dayjs.extend(advancedFormat);
dayjs.extend(customParseFormat);
dayjs.extend(dayJsIsBetween);
dayjs.extend(updateLocale);

/**
* 首字母大写
Expand Down Expand Up @@ -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 });
Expand Down

0 comments on commit 0407105

Please sign in to comment.