Skip to content
This repository was archived by the owner on Apr 17, 2022. It is now read-only.

Commit 9c2a789

Browse files
committed
refactor: Change sanitize date function
1 parent 5e93bf6 commit 9c2a789

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/Vue3DatePicker/utils/date-utils.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ import {
2626

2727
import { IMonthValue, InternalModuleValue, ITimeValue } from '../interfaces';
2828

29-
export const sanitizeDate = (date: Date) => new Date(date.valueOf() + date.getTimezoneOffset() * 60 * 1000);
29+
export const sanitizeDate = (date: Date) => {
30+
const userTimezoneOffset = date.getTimezoneOffset() * 60000;
31+
return new Date(date.getTime() - userTimezoneOffset);
32+
};
3033

3134
export const parseFreeInput = (value: string, pattern: string): Date | null => {
3235
const parsedDate = parse(value, pattern.slice(0, value.length), new Date());

0 commit comments

Comments
 (0)