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 Island from "$lib/islands/island.svelte";
|
||||||
import Header from "$lib/navigation/header.svelte";
|
import Header from "$lib/navigation/header.svelte";
|
||||||
import Loading from "$lib/navigation/loading.svelte";
|
import Loading from "$lib/navigation/loading.svelte";
|
||||||
@ -13,13 +13,16 @@
|
|||||||
return await res.json();
|
return await res.json();
|
||||||
}
|
}
|
||||||
|
|
||||||
function U2L(input) {
|
function U2L(input: Date|number): string {
|
||||||
|
if (input instanceof Date) {
|
||||||
|
return input.toLocaleString();
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
const datetime = new Date(input * 1000);
|
const datetime = new Date(input * 1000);
|
||||||
return datetime.toLocaleString();
|
return datetime.toLocaleString();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
return false;
|
return "Unknown";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
Reference in New Issue
Block a user