From 32093281d62f73576cd8a41c9cfb178b6354f18a Mon Sep 17 00:00:00 2001 From: Simon Cambier Date: Tue, 22 Feb 2022 22:54:01 +0100 Subject: [PATCH] Fixed timezone bug (same as motus) --- src/utils.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/utils.ts b/src/utils.ts index a7d0bbe..a4a7f44 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -7,7 +7,11 @@ export function getCurrentDate(): Date { } export function getCurrentSessionKey(): string { - return getCurrentDate().toISOString().slice(0, 10) + const now = getCurrentDate() + // https://stackoverflow.com/a/28149561 + const tzoffset = now.getTimezoneOffset() * 60000 + const localISOTime = new Date(now.getTime() - tzoffset).toISOString() + return localISOTime.slice(0, 10) } // #region RNG