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:
+15
-27
@@ -58,29 +58,18 @@ function useSensor(measurement, name, end, duration) {
|
|||||||
const memoConvertTZ = (isDST, timeStr, format) => {
|
const memoConvertTZ = (isDST, timeStr, format) => {
|
||||||
if (!timeStr) return '?';
|
if (!timeStr) return '?';
|
||||||
|
|
||||||
let lookUp, result = null;
|
const lookUp = timeStr + format;
|
||||||
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 ) {
|
if (tzcache[lookUp] != undefined ) {
|
||||||
result = tzcache[lookUp];
|
return tzcache[lookUp];
|
||||||
} else {
|
|
||||||
result = moment(timeStr).tz('America/Edmonton').format(format);
|
|
||||||
tzcache[lookUp] = result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let result = moment(timeStr).tz('America/Edmonton').format(format);
|
||||||
if (format === 'HH') {
|
if (format === 'HH') {
|
||||||
return result + ':' + minutes;
|
const minutes = timeStr.slice(14, 16);
|
||||||
} else {
|
result = result + ':' + minutes;
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
tzcache[lookUp] = result;
|
||||||
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
const isDST = end.tz('America/Edmonton').isDST();
|
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) => {
|
const memoConvertTZ = (isDST, timeStr, format) => {
|
||||||
if (!timeStr) return '?';
|
if (!timeStr) return '?';
|
||||||
let lookUp, result = null;
|
const lookUp = timeStr + format;
|
||||||
const date = timeStr.slice(5, 10);
|
if (tzcache[lookUp] != undefined ) { return tzcache[lookUp]; }
|
||||||
const hours = timeStr.slice(11, 13);
|
let result = moment(timeStr).tz('America/Edmonton').format(format);
|
||||||
|
if (format === 'HH') {
|
||||||
const minutes = timeStr.slice(14, 16);
|
const minutes = timeStr.slice(14, 16);
|
||||||
if (format === 'HH') { lookUp = [isDST, hours, format]; }
|
result = result + ':' + minutes;
|
||||||
else { lookUp = [isDST, date, format]; }
|
}
|
||||||
if (tzcache[lookUp] != undefined ) { result = tzcache[lookUp]; }
|
tzcache[lookUp] = result;
|
||||||
else { result = moment(timeStr).tz('America/Edmonton').format(format); tzcache[lookUp] = result; }
|
return result;
|
||||||
if (format === 'HH') { return result + ':' + minutes; }
|
|
||||||
else { return result; }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const isDST = end.tz('America/Edmonton').isDST();
|
const isDST = end.tz('America/Edmonton').isDST();
|
||||||
|
|||||||
Reference in New Issue
Block a user