fix: use full timestamp as cache key in timezone conversion function
Co-authored-by: aider (gemini/gemini-3.1-pro-preview) <aider@aider.chat>
This commit is contained in:
+16
-28
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user