Skip to content

Commit b9bb036

Browse files
committed
SVY-20592 Date Picker shows Invalid DateTime
refactor date validation to improve accuracy
1 parent 004086c commit b9bb036

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

projects/bootstrapcomponents/src/calendar/calendar.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,15 +153,15 @@ export class ServoyBootstrapCalendar extends ServoyBootstrapBaseCalendar {
153153
super.pushUpdate();
154154
}
155155

156-
if ((event !== '' && ((this.minDate && this.minDate > event) || (this.maxDate && this.maxDate < event))) ||
157-
/* 2024.12 fix */
158-
event === undefined ||
159-
/* lts_latest fix */
160-
event.toString() === 'Invalid Date') {
156+
if ((event !== '' && ((this.minDate && this.minDate > event) || (this.maxDate && this.maxDate < event))) || !this.isValidDate(event)) {
161157
// revert to old value
162158
this.svyFormat.writeValue(this.dataProviderID);
163159
}
164160
}
161+
162+
isValidDate(date: any): boolean {
163+
return date instanceof Date && !isNaN(date.getTime());
164+
}
165165

166166
public getNativeChild(): any {
167167
return this.inputElementRef.nativeElement;

0 commit comments

Comments
 (0)