Closed yy7054wyq5 closed 3 years ago
00:00:00
点;而点击后时间则变为当前时间,如16:10:00
,这时候用 getTime()
会不准。你的例子中应该剔除掉 time 仅用 date 来判断
- 升到 11.4.2
- 在日期面板中用来判断是否可点击的时间是当天的
00:00:00
点;而点击后时间则变为当前时间,如16:10:00
,这时候用getTime()
会不准。你的例子中应该剔除掉 time 仅用 date 来判断
disabledEndDate = (endValue: Date): boolean => {
if (!endValue || !this.startValue) {
return false;
}
let range = Infinity;
switch (this.range) {
case 'week':
const ymd = format(addWeeks(this.startValue, 1), 'yyyy-MM-dd');
range = new Date(ymd + ' 23:59:59').getTime();
break;
default:
break;
}
return (
endValue.getTime() <= this.startValue.getTime() ||
endValue.getTime() > range
);
};
我采用的是这种方式,也是可行的。感谢。
要进行比较的两个时间使用moment(date).endOf('days')处理一下也是可以的
Reproduction link
https://stackblitz.com/edit/angular-jqekil?file=src/app/app.component.ts
Steps to reproduce
What is expected?
选中未禁用的最后一天。
What is actually happening?
无法选中未禁用的最后一天。