Skip to content

Commit 70da357

Browse files
committed
SVY-20592 Date Picker shows Invalid DateTime
refactor date validation to improve accuracy
1 parent e179395 commit 70da357

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

projects/bootstrapcomponents/src/calendar/calendar.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,15 +132,15 @@ export class ServoyBootstrapCalendar extends ServoyBootstrapBaseCalendar {
132132
super.pushUpdate();
133133
}
134134

135-
if ((event !== '' && ((this.minDate && this.minDate > event) || (this.maxDate && this.maxDate < event))) ||
136-
/* 2024.12 fix */
137-
event === undefined ||
138-
/* lts_latest fix */
139-
event.toString() === 'Invalid Date') {
135+
if ((event !== '' && ((this.minDate && this.minDate > event) || (this.maxDate && this.maxDate < event))) || !this.isValidDate(event)) {
140136
// revert to old value
141137
this.svyFormat.writeValue(this.dataProviderID);
142138
}
143139
}
140+
141+
isValidDate(date: any): boolean {
142+
return date instanceof Date && !isNaN(date.getTime());
143+
}
144144

145145
public getNativeChild(): any {
146146
return this.inputElementRef.nativeElement;

0 commit comments

Comments
 (0)