From 45bc6d5d395b2f9fd24b908d8cb2f526a12c6f75 Mon Sep 17 00:00:00 2001 From: Eric Wollesen Date: Mon, 9 Feb 2026 12:03:59 +0100 Subject: [PATCH] properly adjust localtime according to localTimezone, if present Previously the code would add a number of minutes equal to the localTimezone. This is not correct, as JS stores dates in UTC. Adding the offset therefore did not adjust the timezone that's displayed, but rather changed the actual time value. Using the moment library, we're able to parse a UTC time then display it in the desired timezone. BACK-4205 --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index e365a04..4a48c2c 100644 --- a/index.js +++ b/index.js @@ -71,8 +71,8 @@ export default class TidepoolDataTools { static addLocalTime(data) { if (data.time) { - const localTime = new Date(data.time); - localTime.setUTCMinutes(localTime.getUTCMinutes() + (data.timezoneOffset || 0)); + const offset = data.timezoneOffset || 0; + const localTime = moment(data.time).utcOffset(offset).format(); _.assign(data, { localTime, });