Refactor task audits, integrate OpenClaw, and fix timezone handling

This commit is contained in:
NPS Agent
2026-05-21 11:33:32 +09:30
parent a9494742bd
commit 98cf813f00
5 changed files with 60 additions and 13 deletions
+19 -4
View File
@@ -74,21 +74,36 @@ function SourceTag({ source }) {
);
}
function getSafeTimezone() {
const tz = window.workspace ? window.workspace.timezone : undefined;
if (!tz) return undefined;
try {
Intl.DateTimeFormat(undefined, { timeZone: tz });
return tz;
} catch (e) {
return undefined; // Fallback to browser time if invalid
}
}
function relTime(iso) {
const now = new Date('2026-05-08T10:30:00');
if (typeof iso === 'string' && !iso.endsWith('Z') && !iso.includes('+')) iso += 'Z';
const now = new Date();
const then = new Date(iso);
const diff = (now - then) / 1000;
if (diff < 60) return 'just now';
if (diff < 3600) return Math.floor(diff/60) + 'm ago';
if (diff < 86400) return Math.floor(diff/3600) + 'h ago';
if (diff < 86400*7) return Math.floor(diff/86400) + 'd ago';
return then.toLocaleDateString('en-US', { month: 'short', day: 'numeric' });
return then.toLocaleDateString('en-US', { month: 'short', day: 'numeric', timeZone: getSafeTimezone() });
}
function fmtDateTime(iso) {
if (typeof iso === 'string' && !iso.endsWith('Z') && !iso.includes('+')) iso += 'Z';
const d = new Date(iso);
return d.toLocaleDateString('en-US', { month: 'short', day: 'numeric' }) +
' · ' + d.toLocaleTimeString('en-US', { hour: 'numeric', minute: '2-digit' });
const tz = getSafeTimezone();
return d.toLocaleDateString('en-US', { month: 'short', day: 'numeric', timeZone: tz }) +
' · ' + d.toLocaleTimeString('en-US', { hour: 'numeric', minute: '2-digit', timeZone: tz });
}
function findUser(id) {