Repository: ant-design/ant-design-mobile (ts)

Issue:
DatePicker选择周日期Bug
### Version of antd-mobile

5.38.1

### Operating system and its version

Others

### Browser and its version

官网

### Sandbox to reproduce

https://mobile.ant.design/zh/components/picker#datepicker

### What happened?


https://github.com/user-attachments/assets/80f2f2e4-5e27-43ec-9c6b-14ac4982d5f3

日期处理从2024年开始就对不上了，选中的和展示的对不上

### Relevant log output

_No response_

Pull request description:
fix(DatePicker): week select with year edge week not working as expect
fix #6807

Patch:
diff --git a/src/components/date-picker/date-picker-week-utils.ts b/src/components/date-picker/date-picker-week-utils.ts
index e6022018c..8100b266a 100644
--- a/src/components/date-picker/date-picker-week-utils.ts
+++ b/src/components/date-picker/date-picker-week-utils.ts
@@ -1,8 +1,8 @@
-import type { ReactNode } from 'react'
 import dayjs from 'dayjs'
+import isLeapYear from 'dayjs/plugin/isLeapYear'
 import isoWeek from 'dayjs/plugin/isoWeek'
 import isoWeeksInYear from 'dayjs/plugin/isoWeeksInYear'
-import isLeapYear from 'dayjs/plugin/isLeapYear'
+import type { ReactNode } from 'react'
 import { PickerColumn } from '../picker'
 import type { DatePickerFilter } from './date-picker-utils'
 
@@ -123,13 +123,12 @@ export function convertDateToStringArray(
 }
 
 export function convertStringArrayToDate<
-  T extends string | number | null | undefined
+  T extends string | number | null | undefined,
 >(value: T[]): Date {
   const yearString = value[0] ?? '1900'
   const weekString = value[1] ?? '1'
   const weekdayString = value[2] ?? '1'
-  const day = dayjs()
-    .year(parseInt(yearString as string))
+  const day = dayjs(`${parseInt(yearString as string)}-01-01`)
     .isoWeek(parseInt(weekString as string))
     .isoWeekday(parseInt(weekdayString as string))
     .hour(0)


Test patch:
diff --git a/src/components/date-picker/tests/date-picker.test.tsx b/src/components/date-picker/tests/date-picker.test.tsx
index 8fc0527c5..398098845 100644
--- a/src/components/date-picker/tests/date-picker.test.tsx
+++ b/src/components/date-picker/tests/date-picker.test.tsx
@@ -1,17 +1,18 @@
+import dayjs from 'dayjs'
+import * as React from 'react'
 import {
-  render,
-  testA11y,
+  act,
   fireEvent,
-  waitFor,
+  render,
   screen,
   sleep,
-  act,
+  testA11y,
+  waitFor,
   waitForElementToBeRemoved,
 } from 'testing'
-import * as React from 'react'
 import DatePicker from '../'
-import dayjs from 'dayjs'
 import Button from '../../button'
+import { convertStringArrayToDate } from '../date-picker-week-utils'
 
 const classPrefix = `adm-picker`
 
@@ -205,4 +206,16 @@ describe('DatePicker', () => {
     expect(res.toDateString()).toEqual(now.toDateString())
     expect(res.tillNow).toBeTruthy()
   })
+
+  test('convertStringArrayToDate of week should correct', () => {
+    // jest mock today is `2024-12-30`
+    jest.useFakeTimers({
+      now: new Date('2024-12-30'),
+    })
+
+    const date = convertStringArrayToDate(['2024', '1', '1'])
+    expect(date.getFullYear()).toBe(2024)
+    expect(date.getMonth()).toBe(0)
+    expect(date.getDate()).toBe(1)
+  })
 })