Allow statistics to handle date ibject or timestamp
This commit is contained in:
parent
cd0e051a5a
commit
3db490a0bb
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user