diff --git a/webapp/src/components/EventLog.vue b/webapp/src/components/EventLog.vue index db2b58382..93877536a 100644 --- a/webapp/src/components/EventLog.vue +++ b/webapp/src/components/EventLog.vue @@ -31,7 +31,7 @@ export default defineComponent({ computed: { timeInHours() { return (value: number) => { - return timestampToString(value); + return timestampToString(this.$i18n.locale, value)[0]; }; }, }, diff --git a/webapp/src/components/FirmwareInfo.vue b/webapp/src/components/FirmwareInfo.vue index 6dd69a14c..5687c1045 100644 --- a/webapp/src/components/FirmwareInfo.vue +++ b/webapp/src/components/FirmwareInfo.vue @@ -49,7 +49,7 @@ {{ $t('firmwareinfo.Uptime') }} - {{ timeInHours(systemStatus.uptime) }} + {{ $t('firmwareinfo.UptimeValue', timeInHours(systemStatus.uptime)) }} @@ -73,7 +73,8 @@ export default defineComponent({ computed: { timeInHours() { return (value: number) => { - return timestampToString(value, true); + const [count, time] = timestampToString(this.$i18n.locale, value, true); + return {count, time}; }; }, versionInfoUrl(): string { diff --git a/webapp/src/locales/de.json b/webapp/src/locales/de.json index af36fdcaa..9afd00140 100644 --- a/webapp/src/locales/de.json +++ b/webapp/src/locales/de.json @@ -188,7 +188,8 @@ "ResetReason0": "Reset Grund CPU 0", "ResetReason1": "Reset Grund CPU 1", "ConfigSaveCount": "Anzahl der Konfigurationsspeicherungen", - "Uptime": "Betriebszeit" + "Uptime": "Betriebszeit", + "UptimeValue": "0 Tage {time} | 1 Tag {time} | {count} Tage {time}" }, "hardwareinfo": { "HardwareInformation": "Hardwareinformationen", diff --git a/webapp/src/locales/en.json b/webapp/src/locales/en.json index 007b9d0b9..e23111610 100644 --- a/webapp/src/locales/en.json +++ b/webapp/src/locales/en.json @@ -188,7 +188,8 @@ "ResetReason0": "Reset Reason CPU 0", "ResetReason1": "Reset Reason CPU 1", "ConfigSaveCount": "Config save count", - "Uptime": "Uptime" + "Uptime": "Uptime", + "UptimeValue": "0 days {time} | 1 day {time} | {count} days {time}" }, "hardwareinfo": { "HardwareInformation": "Hardware Information", diff --git a/webapp/src/locales/fr.json b/webapp/src/locales/fr.json index 9a2e6a930..c7087c450 100644 --- a/webapp/src/locales/fr.json +++ b/webapp/src/locales/fr.json @@ -188,7 +188,8 @@ "ResetReason0": "Raison de la réinitialisation CPU 0", "ResetReason1": "Raison de la réinitialisation CPU 1", "ConfigSaveCount": "Nombre d'enregistrements de la configuration", - "Uptime": "Temps de fonctionnement" + "Uptime": "Durée de fonctionnement", + "UptimeValue": "0 jour {time} | 1 jour {time} | {count} jours {time}" }, "hardwareinfo": { "HardwareInformation": "Informations sur le matériel", @@ -616,4 +617,4 @@ "ValueSelected": "Sélectionné", "ValueActive": "Activé" } -} +} \ No newline at end of file diff --git a/webapp/src/utils/time.ts b/webapp/src/utils/time.ts index 6e0224038..afdb1fff9 100644 --- a/webapp/src/utils/time.ts +++ b/webapp/src/utils/time.ts @@ -1,8 +1,8 @@ -export const timestampToString = (timestampSeconds: number, includeDays = false): string => { - const timeString = new Date(timestampSeconds * 1000).toLocaleTimeString([], { timeZone: "UTC" }); - if (!includeDays) return timeString; +export const timestampToString = (locale: string, timestampSeconds: number, includeDays = false): string[] => { + const timeString = new Date(timestampSeconds * 1000).toLocaleTimeString(locale, { timeZone: "UTC", hour12: false }); + if (!includeDays) return [timeString]; const secondsPerDay = 60 * 60 * 24; - const days = Math.floor(timestampSeconds / secondsPerDay); - return new Intl.RelativeTimeFormat().format(-days, "day") + " " + timeString; + const days = Math.floor(timestampSeconds / secondsPerDay).toFixed(0); + return [days, timeString]; } \ No newline at end of file