Respect DISPLAY_TIMEZONE in GC and integrity scanner history tables

This commit is contained in:
2026-03-23 18:36:13 +08:00
parent 1a5a7aa9e1
commit f60dbaf9c9
2 changed files with 13 additions and 5 deletions

View File

@@ -4126,7 +4126,7 @@ def system_dashboard():
r = rec.get("result", {}) r = rec.get("result", {})
total_freed = r.get("temp_bytes_freed", 0) + r.get("multipart_bytes_freed", 0) + r.get("orphaned_version_bytes_freed", 0) total_freed = r.get("temp_bytes_freed", 0) + r.get("multipart_bytes_freed", 0) + r.get("orphaned_version_bytes_freed", 0)
rec["bytes_freed_display"] = _format_bytes(total_freed) rec["bytes_freed_display"] = _format_bytes(total_freed)
rec["timestamp_display"] = datetime.fromtimestamp(rec["timestamp"], tz=dt_timezone.utc).strftime("%Y-%m-%d %H:%M UTC") rec["timestamp_display"] = _format_datetime_display(datetime.fromtimestamp(rec["timestamp"], tz=dt_timezone.utc))
gc_history_records.append(rec) gc_history_records.append(rec)
checker = current_app.extensions.get("integrity") checker = current_app.extensions.get("integrity")
@@ -4135,7 +4135,7 @@ def system_dashboard():
if checker: if checker:
raw = checker.get_history(limit=10, offset=0) raw = checker.get_history(limit=10, offset=0)
for rec in raw: for rec in raw:
rec["timestamp_display"] = datetime.fromtimestamp(rec["timestamp"], tz=dt_timezone.utc).strftime("%Y-%m-%d %H:%M UTC") rec["timestamp_display"] = _format_datetime_display(datetime.fromtimestamp(rec["timestamp"], tz=dt_timezone.utc))
integrity_history_records.append(rec) integrity_history_records.append(rec)
features = [ features = [
@@ -4163,6 +4163,7 @@ def system_dashboard():
gc_history=gc_history_records, gc_history=gc_history_records,
integrity_status=integrity_status, integrity_status=integrity_status,
integrity_history=integrity_history_records, integrity_history=integrity_history_records,
display_timezone=current_app.config.get("DISPLAY_TIMEZONE", "UTC"),
) )

View File

@@ -387,11 +387,18 @@
return (i === 0 ? b : b.toFixed(1)) + ' ' + units[i]; return (i === 0 ? b : b.toFixed(1)) + ' ' + units[i];
} }
var _displayTimezone = {{ display_timezone|tojson }};
function formatTimestamp(ts) { function formatTimestamp(ts) {
var d = new Date(ts * 1000); var d = new Date(ts * 1000);
var pad = function (n) { return n < 10 ? '0' + n : '' + n; }; try {
return d.getUTCFullYear() + '-' + pad(d.getUTCMonth() + 1) + '-' + pad(d.getUTCDate()) + var opts = {year: 'numeric', month: 'short', day: '2-digit', hour: '2-digit', minute: '2-digit', hour12: false, timeZone: _displayTimezone, timeZoneName: 'short'};
' ' + pad(d.getUTCHours()) + ':' + pad(d.getUTCMinutes()) + ' UTC'; return d.toLocaleString('en-US', opts);
} catch (e) {
var pad = function (n) { return n < 10 ? '0' + n : '' + n; };
return d.getUTCFullYear() + '-' + pad(d.getUTCMonth() + 1) + '-' + pad(d.getUTCDate()) +
' ' + pad(d.getUTCHours()) + ':' + pad(d.getUTCMinutes()) + ' UTC';
}
} }
var _gcHistoryIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" fill="currentColor" viewBox="0 0 16 16">' + var _gcHistoryIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" fill="currentColor" viewBox="0 0 16 16">' +