fix #1649
one of the goals of my pull request, besides simplifying the code was to have localization. It's nice that the browser can handle this, but for consistency, we'll go with vue-i18n since it is already available
This commit is contained in:
parent
6233ad12ae
commit
f26e824247
@ -31,7 +31,7 @@ export default defineComponent({
|
||||
computed: {
|
||||
timeInHours() {
|
||||
return (value: number) => {
|
||||
return timestampToString(value);
|
||||
return timestampToString(this.$i18n.locale, value)[0];
|
||||
};
|
||||
},
|
||||
},
|
||||
|
||||
@ -49,7 +49,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<th>{{ $t('firmwareinfo.Uptime') }}</th>
|
||||
<td>{{ timeInHours(systemStatus.uptime) }}</td>
|
||||
<td>{{ $t('firmwareinfo.UptimeValue', timeInHours(systemStatus.uptime)) }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@ -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 {
|
||||
|
||||
@ -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",
|
||||
|
||||
@ -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",
|
||||
|
||||
@ -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",
|
||||
|
||||
@ -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];
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user