Skip to content

Commit 1a49108

Browse files
committed
refactor(Calendar): improve time zones handling when selection type is month or year
1 parent 46d447a commit 1a49108

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

js/src/util/calendar.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ export const convertToDateObject = (date, selectionType) => {
2323
return convertIsoWeekToDate(date)
2424
}
2525

26+
if (selectionType === 'month' || selectionType === 'year') {
27+
const _date = new Date(Date.parse(date))
28+
const userTimezoneOffset = _date.getTimezoneOffset() * 60_000
29+
return new Date(_date.getTime() + userTimezoneOffset)
30+
}
31+
2632
return new Date(Date.parse(date))
2733
}
2834

0 commit comments

Comments
 (0)