Skip to content

Commit

Permalink
fix(date-picker): 修复datepicker显示农历时2月中1月农历显示错误问题 (#2853)
Browse files Browse the repository at this point in the history
  • Loading branch information
maoguoping committed Jun 6, 2024
1 parent 33f44eb commit b4945c3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/olive-trains-joke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@hi-ui/hiui": patch
---

fix(date-picker): 修复 datepicker 显示农历时 2 月中 1 月农历显示错误问题
5 changes: 5 additions & 0 deletions .changeset/tidy-rings-burn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@hi-ui/date-picker": patch
---

fix(date-picker): 修复 datepicker 显示农历时 2 月中 1 月农历显示错误问题(#2853)
3 changes: 2 additions & 1 deletion packages/ui/date-picker/src/utils/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -198,13 +198,14 @@ export const getFullTime = ({
}) => {
if (cell.type === 'disabled') return false
const newDate = moment(renderDate)
newDate.date(cell.value)
// 先设置月份,防止赋值出月中不存在日期
if (cell.type === 'prev') {
newDate.subtract(1, 'months')
}
if (cell.type === 'next') {
newDate.add(1, 'months')
}
newDate.date(cell.value)
const _year = newDate.year()
const _month = newDate.month() + 1
const _value = cell.value
Expand Down

0 comments on commit b4945c3

Please sign in to comment.