Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Datepicker的min值判断的问题 #119

Open
lzj723 opened this issue Aug 10, 2018 · 2 comments
Open

Datepicker的min值判断的问题 #119

lzj723 opened this issue Aug 10, 2018 · 2 comments

Comments

@lzj723
Copy link

lzj723 commented Aug 10, 2018

案例1(正常,最小可选日期是2018-08-12):
<Datepicker type="datetime"
min={"2018-08-12 12:00:00"}
value={"2018-08-10 11:00:00"}
/>
案例2(异常,最小可选日期是2018-08-11):
<Datepicker type="datetime"
min={"2018-08-10 12:00:00"}
value={"2018-08-15 15:00:00"}
/>

以上2个按钮
《案例1》是正常的,最小可选日期是2018-08-12,因为11:00:00时间上小于12:00:00;
《案例2》同样的配置,只是值不同,它的最小可选日期就变成2018-08-11了,因为15:00:00时间上大于12:00:00;
问题应该是出在Datetime.js的renderDays方法不应该拿current的时间去比较min值,当尝试把hour、minute、second全部用0时,又出现了value是min当天时,时间选择可能会比min时间小的情况。
=====Datetime.js=====
let hour = current.getHours()
let minute = current.getMinutes()
let second = current.getSeconds()
......
for (let date, i = 0; i < end; i++) {
date = new Date(year, month, i + first, hour, minute, second)
days.push(date)
}
......
if (min > 0) {
disabled = speedTime + 86399000 < min
}

@lzj723
Copy link
Author

lzj723 commented Aug 11, 2018

另外通过上下箭头增减小时的时候,指针会跟着变,但是AM/PM不会自动切换

@Lobos
Copy link
Owner

Lobos commented Aug 12, 2018

感谢指出,已修复。第一个问题,是出在 + 86399000 上。因为之前有个问题,就是设置为2018-08-10 12:00:00后,默认状态下,2018-08-10是不可选的,必须把时间部分先改为大于 12:00:00 的时间,才可以选,所以判断最小时间的时候减了23小时59分59秒,但是这样确实造成了前一天不可选的变成可选了。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants