Skip to content

Commit 6da51e3

Browse files
committed
SVY-20592 Date Picker shows Invalid DateTime
refactor date validation to improve accuracy
1 parent dd73091 commit 6da51e3

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

  • components/projects/bootstrapcomponents/src/calendar

components/projects/bootstrapcomponents/src/calendar/calendar.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,15 +137,15 @@ export class ServoyBootstrapCalendar extends ServoyBootstrapBaseCalendar {
137137
super.pushUpdate();
138138
}
139139

140-
if ((event !== '' && ((this.minDate && this.minDate > event) || (this.maxDate && this.maxDate < event))) ||
141-
/* 2024.12 fix */
142-
event === undefined ||
143-
/* lts_latest fix */
144-
event.toString() === 'Invalid Date') {
140+
if ((event !== '' && ((this.minDate && this.minDate > event) || (this.maxDate && this.maxDate < event))) || !this.isValidDate(event)) {
145141
// revert to old value
146142
this.svyFormat.writeValue(this.dataProviderID);
147143
}
148144
}
145+
146+
isValidDate(date: any): boolean {
147+
return date instanceof Date && !isNaN(date.getTime());
148+
}
149149

150150
public getNativeChild(): any {
151151
return this.inputElementRef.nativeElement;

0 commit comments

Comments
 (0)