Skip to content

Commit b2eb69e

Browse files
JianJroh07akioni
andauthored
fix(date-picker): use local week and local year as default weekFormat (#6234)
Co-authored-by: 07akioni <[email protected]>
1 parent b60bd7f commit b2eb69e

34 files changed

+35
-32
lines changed

CHANGELOG.en-US.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
### Breaking Changes
88

99
- Fix `n-config-provider` inherit the class prefix from it's parent by default, closes [#5970](https://github.com/tusen-ai/naive-ui/issues/5970).
10+
- Fix `n-date-picker` default `weekFormat` that year and week standards are different and use local week and local year
1011

1112
### Fixes
1213

CHANGELOG.zh-CN.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
### Breaking Changes
88

99
- 修复 `n-config-provider` 默认继承父级的类前缀 `cls-prefix`, 关闭 [#5970](https://github.com/tusen-ai/naive-ui/issues/5970)
10+
- 修复 `n-date-picker` 默认 `weekFormat` 中 year 和 week 标准不同,使用 local year 和 local week
1011

1112
### Fixes
1213

src/date-picker/demos/enUS/index.demo-entry.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ panel.vue
178178
| --- | --- | --- | --- | --- |
179179
| actions | `Array<'clear' \| 'now'> \| null` | `['clear', 'now']` | Operations supported for the `week` type date picker. | 2.37.0 |
180180
| default-calendar-start-time | `number` | `undefined` | Default panel calendar start month timestamp. | 2.38.1 |
181-
| format | `string` | `'yyyy-w'` for en-US, Locale specific. | Format of the input. For detail please see [format](https://date-fns.org/v2.23.0/docs/format). | 2.37.0 |
181+
| format | `string` | `'YYYY-w'` for en-US, Locale specific. | Format of the input. For detail please see [format](https://date-fns.org/v2.23.0/docs/format). | 2.37.0 |
182182
| placeholder | `string` | `'Select Week'` for en-US, Locale specific. | Placeholder. | 2.37.0 |
183183
| on-update:formatted-value | `(value: string \| null, timestampValue: number \| null) => void` | `undefined` | Formatted value changed callback. | 2.37.0 |
184184
| on-update:value | `(value: number \| null, formattedValue: string \| null) => void` | `undefined` | Value changed callback. | 2.37.0 |

src/date-picker/demos/zhCN/index.demo-entry.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ form-debug.vue
178178
| --- | --- | --- | --- | --- |
179179
| actions | `Array<'clear' \| 'now'> \| null` | `['clear', 'now']` | Week 类型的 Date Picker 中支持的操作 | 2.37.0 |
180180
| default-calendar-start-time | `number` | `undefined` | 面板日历默认开始的月份时间戳 | 2.38.1 |
181-
| format | `string` | 中文为 `'yyyy-w'`,随语言变化 | 时间格式化字符串,详情见 [format](https://date-fns.org/v2.23.0/docs/format) | 2.37.0 |
181+
| format | `string` | 中文为 `'YYYY-w'`,随语言变化 | 时间格式化字符串,详情见 [format](https://date-fns.org/v2.23.0/docs/format) | 2.37.0 |
182182
| placeholder | `string` | 中文为 `'选择周'`,随语言变化 | 没有值时的占位信息 | 2.37.0 |
183183
| on-update:formatted-value | `(value: string \| null, timestampValue: number \| null) => void` | `undefined` | 受控数据更新时触发的回调函数 | 2.37.0 |
184184
| on-update:value | `(value: number \| null, formattedValue: string \| null) => void` | `undefined` | 受控数据更新时触发的回调函数 | 2.37.0 |

src/date-picker/src/DatePicker.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ export default defineComponent({
9999
const mergedShowRef = useMergedState(controlledShowRef, uncontrolledShowRef)
100100
const dateFnsOptionsRef = computed(() => {
101101
return {
102-
locale: dateLocaleRef.value.locale
102+
locale: dateLocaleRef.value.locale,
103+
useAdditionalWeekYearTokens: true
103104
}
104105
})
105106

src/locales/common/arDZ.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const arDZ: NLocale = {
3131
dateFormat: 'yyyy-MM-dd',
3232
dateTimeFormat: 'yyyy-MM-dd HH:mm:ss',
3333
quarterFormat: 'yyyy-qqq',
34-
weekFormat: 'RRRR-w',
34+
weekFormat: 'YYYY-w',
3535
clear: 'مسح',
3636
now: 'الآن',
3737
confirm: 'تأكيد',

src/locales/common/azAZ.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const azAZ: NLocale = {
3131
dateFormat: 'dd MMMM yyyy',
3232
dateTimeFormat: 'yyyy-MM-dd HH:mm:ss',
3333
quarterFormat: 'yyyy-qqq',
34-
weekFormat: 'yyyy-w',
34+
weekFormat: 'YYYY-w',
3535
clear: 'Təmizlə',
3636
now: 'İndi',
3737
confirm: 'Təsdiqlə',

src/locales/common/csCZ.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const csCZ: NLocale = {
3131
dateFormat: 'd-M-yyyy',
3232
dateTimeFormat: 'd-M-yyyy HH:mm:ss',
3333
quarterFormat: 'qqq-yyyy',
34-
weekFormat: 'RRRR-w',
34+
weekFormat: 'YYYY-w',
3535
clear: 'Vyčistit',
3636
now: 'Teď',
3737
confirm: 'Potvrdit',

src/locales/common/deDE.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const deDE: NLocale = {
3131
dateFormat: 'dd.MM.yyyy',
3232
dateTimeFormat: 'dd.MM.yyyy HH:mm:ss',
3333
quarterFormat: 'yyyy-qqq',
34-
weekFormat: 'RRRR-w',
34+
weekFormat: 'YYYY-w',
3535
clear: 'Löschen',
3636
now: 'Jetzt',
3737
confirm: 'Bestätigen',

src/locales/common/enGB.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const enGB: NLocale = {
3131
dateFormat: 'yyyy/MM/dd',
3232
dateTimeFormat: 'yyyy/MM/dd HH:mm:ss',
3333
quarterFormat: 'yyyy-qqq',
34-
weekFormat: 'RRRR-w',
34+
weekFormat: 'YYYY-w',
3535
clear: 'Clear',
3636
now: 'Now',
3737
confirm: 'Confirm',

0 commit comments

Comments
 (0)