From bef6796da49d41c8adecd88c21cc09a79014829a Mon Sep 17 00:00:00 2001 From: Raymond Zhou <56318341+rayzhou-bit@users.noreply.github.com> Date: Wed, 24 Apr 2024 09:07:15 -0700 Subject: [PATCH] fix: errors for positive time zones (#961) --- src/utils.js | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/src/utils.js b/src/utils.js index 1a16977b1..d4bc8f6ff 100644 --- a/src/utils.js +++ b/src/utils.js @@ -267,24 +267,7 @@ export const convertToDateFromString = (dateStr) => { const stripTimeZone = (stringValue) => stringValue.substring(0, 19); - const differenceDueToDST = (date) => { - const isNowDST = moment(new Date()).isDST(); - const isDateDST = moment(date).isDST(); - if (isNowDST && !isDateDST) { - return 1; - } - if (!isNowDST && isDateDST) { - return -1; - } - return 0; - }; - - const timeZoneOffset = new Date().getTimezoneOffset(); - const timeZoneHours = (Math.abs(timeZoneOffset) / 60) + differenceDueToDST(moment(dateStr)); - const sign = timeZoneOffset < 0 ? '+' : '-'; - const timeZone = `${sign}${String(timeZoneHours).padStart(2, '0')}00`; - - return moment(stripTimeZone(String(dateStr)) + timeZone).toDate(); + return moment(stripTimeZone(String(dateStr))).toDate(); }; export const convertToStringFromDate = (date) => {