Open Leon-Shaw opened 2 months ago
I can only use it this way now, but it's not beautiful enough
disabledDate = (time: Date): boolean => {
const endTimeDateOnly = new Date(this.endTime);
endTimeDateOnly.setHours(0, 0, 0, 0);
const endTimeEndOfDay = new Date(endTimeDateOnly.getTime() + 24 * 60 * 60 * 1000 - 1);
return new Date(time) < new Date(this.startTime) || new Date(time) > endTimeEndOfDay;
};
same problem
stackblitz.com/edit/angular-taetoz?file=src%2Fapp%2Fapp.component.ts
You can use differenceInCalendarDays
of date-fns
lib instead
disabledDate = (time: Date): boolean => {
return (
differenceInCalendarDays(new Date('2024-09-16'), time) > 0 ||
differenceInCalendarDays(time, new Date('2024-09-30')) > 0
);
};
Reproduction link
https://stackblitz.com/edit/angular-taetoz?file=src%2Fapp%2Fapp.component.ts
Steps to reproduce
What is expected?
The deadline of September 30th can be selected
What is actually happening?
The component did not respond after clicking on the deadline of September 30th