-
Notifications
You must be signed in to change notification settings - Fork 323
Closed
Labels
🐞 bugSomething isn't workingSomething isn't working🧐 unconfirmedwaiting to be confirmedwaiting to be confirmed
Description
tdesign-miniprogram 版本
1.10.1
重现链接
No response
重现步骤
Calendar 组件设置:
value=new Date(2025, 9, 11);
min-date = new Date(2025, 8, 11); ,
max-date = new Date(2025, 10, 11);
switch-mode=month;
- 点击日历上的10月31号,会发现下一个月的按钮无法点击。
期望结果
下一个月的按钮可点击,因为当前仍然处于10月,且最大日期时11月11日。
实际结果
下一月按钮无法点击
基础库版本
No response
补充说明
具体原因为getMonthByOffset 方法有问题。
假设 Date value = new Date(yyyy, mm, dd);
getMonthByOffset(value, n);
如果value + n 月那一天没有 dd, 则会自动进入下一个月,也就是value+n+1.
https://github.com/Tencent/tdesign-miniprogram/blob/develop/packages/components/calendar/utils.ts
function getMonthByOffset(t, e) {
const n = new Date(t);
return n.setMonth(n.getMonth() + e), n.setDate(1), n;
}getMonthByOffset 计算结果有误。
getMonthByOffset(new Date(2025, 9, 30), 1) --> Sat Nov 01 2025 00:00:00 GMT+0800 (China Standard Time)
getMonthByOffset(new Date(2025, 9, 31), 1) --> Mon Dec 01 2025 00:00:00 GMT+0800 (China Standard Time)
Metadata
Metadata
Assignees
Labels
🐞 bugSomething isn't workingSomething isn't working🧐 unconfirmedwaiting to be confirmedwaiting to be confirmed