Serverpuls: Zeitzone in Warnungen
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
57f235dd36
commit
03af5fcfb8
3 files changed
+15
-7
No files matched your search
@@ -89,3 +89,9 @@ export function formatLegendTime(sec) {
|
||||
if (sec === null || sec === undefined) return '–'
|
||||
return F.legend.format(new Date(sec * 1000))
|
||||
}
|
||||
|
||||
// "seit"-Zeitpunkt in Warnungen, immer Berliner Zeit.
|
||||
export function formatSince(ts) {
|
||||
if (!ts) return ''
|
||||
return new Date(ts).toLocaleString('de-DE', { dateStyle: 'short', timeStyle: 'short', timeZone: 'Europe/Berlin' })
|
||||
}
|
||||
@@ -4,7 +4,7 @@ import { useAuth } from '../context/AuthContext'
|
||||
import { PageHeader } from '../components/ui'
|
||||
import { serverpulsApi } from '../lib/serverpulsApi'
|
||||
import {
|
||||
ageLabel, formatBytes, formatNumber, formatPct, usedPct,
|
||||
ageLabel, formatBytes, formatNumber, formatPct, formatSince, usedPct,
|
||||
} from '../lib/serverpulsFormat'
|
||||
import Chart from '../components/serverpuls/Chart'
|
||||
import Sparkline from '../components/serverpuls/Sparkline'
|
||||
@@ -31,11 +31,6 @@ const METRICS = [
|
||||
const LEVEL_TEXT = { ok: 'Alles ok', medium: 'Warnungen', critical: 'Critical' }
|
||||
const LEVEL_LABEL = { critical: 'Critical', medium: 'Medium', low: 'Low' }
|
||||
|
||||
function fmtSince(ts) {
|
||||
if (!ts) return ''
|
||||
return new Date(ts).toLocaleString('de-DE', { dateStyle: 'short', timeStyle: 'short' })
|
||||
}
|
||||
|
||||
// Verlaufswerte in Anzeigewerte umrechnen (RAM: frei -> belegt).
|
||||
function displayPoints(metric, points, total) {
|
||||
if (metric !== 'ram') return points
|
||||
@@ -279,7 +274,7 @@ export default function ServerpulsPage() {
|
||||
<span className="sp-alert-level">{LEVEL_LABEL[a.level] || a.level}</span>
|
||||
<span className="sp-alert-title">{a.title}</span>
|
||||
<span className="sp-alert-value">{a.value}</span>
|
||||
<span className="sp-muted sp-small">seit {fmtSince(a.since)}</span>
|
||||
<span className="sp-muted sp-small">seit {formatSince(a.since)}</span>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
|
||||
@@ -52,3 +52,10 @@ test('Zeitachse: deutsche Ausgabe in Europe/Berlin', () => {
|
||||
assert.equal(formatLegendTime(t), '30.09.2026, 11:20')
|
||||
assert.equal(formatLegendTime(null), '–')
|
||||
})
|
||||
|
||||
test('formatSince: Europe/Berlin, unabhängig von der Prozess-Zeitzone', async () => {
|
||||
const { formatSince } = await loadModule('src/lib/serverpulsFormat.js')
|
||||
assert.equal(formatSince(Date.UTC(2026, 6, 1, 10, 0, 0)), '01.07.26, 12:00')
|
||||
assert.equal(formatSince(Date.UTC(2026, 0, 1, 10, 0, 0)), '01.01.26, 11:00')
|
||||
assert.equal(formatSince(0), '')
|
||||
})
|
||||
Reference in new issue
Block a user