Fix timezone formatting in client timeUtils

This commit is contained in:
nmemmert committed 2025-12-15 13:40:51 -05:00
1 parent c7577f6ce2
commit 91bc41aa5f
7 files changed
+17 -12

No files matched your search

+9 -4
View File
@@ -22,9 +22,11 @@ export const formatLocalTime = (timestamp, options = {}) => {
let timeZone;
try {
const cachedSettings = localStorage.getItem('serverTimezone');
timeZone = cachedSettings || undefined; // Use browser TZ if not set
if (cachedSettings && cachedSettings !== 'null' && cachedSettings !== 'undefined') {
timeZone = cachedSettings;
}
} catch (e) {
timeZone = undefined;
// Ignore errors
}
const defaultOptions = {
@@ -34,10 +36,13 @@ export const formatLocalTime = (timestamp, options = {}) => {
hour: '2-digit',
minute: '2-digit',
second: '2-digit',
timeZoneName: 'short',
...(timeZone && { timeZone })
timeZoneName: 'short'
};
if (timeZone) {
defaultOptions.timeZone = timeZone;
}
return date.toLocaleString('en-US', { ...defaultOptions, ...options });
};