From 242e3148c7211b11f72538ebe7eb9990e9bccfcf Mon Sep 17 00:00:00 2001 From: Tanner Date: Tue, 25 Aug 2026 23:21:45 +0000 Subject: [PATCH] fix: use full timestamp as cache key in timezone conversion function Co-authored-by: aider (gemini/gemini-3.1-pro-preview) --- client/src/App.js | 44 ++++++++++++++++---------------------------- 1 file changed, 16 insertions(+), 28 deletions(-) diff --git a/client/src/App.js b/client/src/App.js index 205ccc4..6cecca0 100644 --- a/client/src/App.js +++ b/client/src/App.js @@ -58,29 +58,18 @@ function useSensor(measurement, name, end, duration) { const memoConvertTZ = (isDST, timeStr, format) => { if (!timeStr) return '?'; - let lookUp, result = null; - const date = timeStr.slice(5, 10); - const hours = timeStr.slice(11, 13); - const minutes = timeStr.slice(14, 16); - - if (format === 'HH') { - lookUp = [isDST, hours, format]; - } else { - lookUp = [isDST, date, format]; - } - + const lookUp = timeStr + format; if (tzcache[lookUp] != undefined ) { - result = tzcache[lookUp]; - } else { - result = moment(timeStr).tz('America/Edmonton').format(format); - tzcache[lookUp] = result; + return tzcache[lookUp]; } + let result = moment(timeStr).tz('America/Edmonton').format(format); if (format === 'HH') { - return result + ':' + minutes; - } else { - return result; + const minutes = timeStr.slice(14, 16); + result = result + ':' + minutes; } + tzcache[lookUp] = result; + return result; }; const isDST = end.tz('America/Edmonton').isDST(); @@ -721,16 +710,15 @@ function MultiLineChart({title, measurement, dataKey, sensors, colors, end, dura const memoConvertTZ = (isDST, timeStr, format) => { if (!timeStr) return '?'; - let lookUp, result = null; - const date = timeStr.slice(5, 10); - const hours = timeStr.slice(11, 13); - const minutes = timeStr.slice(14, 16); - if (format === 'HH') { lookUp = [isDST, hours, format]; } - else { lookUp = [isDST, date, format]; } - if (tzcache[lookUp] != undefined ) { result = tzcache[lookUp]; } - else { result = moment(timeStr).tz('America/Edmonton').format(format); tzcache[lookUp] = result; } - if (format === 'HH') { return result + ':' + minutes; } - else { return result; } + const lookUp = timeStr + format; + if (tzcache[lookUp] != undefined ) { return tzcache[lookUp]; } + let result = moment(timeStr).tz('America/Edmonton').format(format); + if (format === 'HH') { + const minutes = timeStr.slice(14, 16); + result = result + ':' + minutes; + } + tzcache[lookUp] = result; + return result; }; const isDST = end.tz('America/Edmonton').isDST();