Allow statistics to handle date ibject or timestamp

This commit is contained in:
Fred Boniface 2024-06-23 23:47:47 +01:00
parent cd0e051a5a
commit 3db490a0bb

View File

@ -1,4 +1,4 @@
<script>
<script lang="ts">
import Island from "$lib/islands/island.svelte";
import Header from "$lib/navigation/header.svelte";
import Loading from "$lib/navigation/loading.svelte";
@ -13,13 +13,16 @@
return await res.json();
}
function U2L(input) {
function U2L(input: Date|number): string {
if (input instanceof Date) {
return input.toLocaleString();
}
try {
const datetime = new Date(input * 1000);
return datetime.toLocaleString();
} catch (err) {
console.log(err);
return false;
return "Unknown";
}
}
</script>