Skip to content

Commit 5568a13

Browse files
fix(AUT-2298): Bug fix for years that default incorrectly (#568)
1 parent d96fc8c commit 5568a13

File tree

1 file changed

+6
-1
lines changed
  • src/components/experimental/DatePicker/util

1 file changed

+6
-1
lines changed

src/components/experimental/DatePicker/util/index.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,10 @@ export function dateToCalendarDate(d: Date): CalendarDate {
6161
}
6262

6363
export function calendarDateToDate(dv: DateValue): Date {
64-
return new Date(dv.year, dv.month - 1, dv.day);
64+
const d = new Date(dv.year, dv.month - 1, dv.day);
65+
// `new Date()` treats 2-digit years as 19xx, `setFullYear` corrects this.
66+
if (dv.year < 100) {
67+
d.setFullYear(dv.year);
68+
}
69+
return d;
6570
}

0 commit comments

Comments
 (0)