From 84ce8a93f34796a0851117e95b5a33eb4a359d32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Sat, 1 Jun 2024 00:40:22 +0200 Subject: [PATCH] Refactor ISOToDateTime to handle case when timezone's server is UTC A condition is added to check if the timezone is set as '0000' (UTC timezone), if yes then a new Date is returned with the Date.UTC method. This ensures that the time returned correctly reflects the current timezone --- src/Bundle/ChillMainBundle/Resources/public/chill/js/date.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Bundle/ChillMainBundle/Resources/public/chill/js/date.ts b/src/Bundle/ChillMainBundle/Resources/public/chill/js/date.ts index 8c087146a..9198f835e 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/chill/js/date.ts +++ b/src/Bundle/ChillMainBundle/Resources/public/chill/js/date.ts @@ -59,6 +59,10 @@ export const ISOToDatetime = (str: string|null): Date|null => { [hours, minutes, seconds] = time.split(':').map(s => parseInt(s)); ; + if ('0000' === timezone) { + return new Date(Date.UTC(year, month-1, date, hours, minutes, seconds)); + } + return new Date(year, month-1, date, hours, minutes, seconds); }