mirror of
https://github.com/mickael-kerjean/filestash
synced 2025-12-12 03:13:12 +01:00
fix (time): better date formating
This commit is contained in:
parent
5c87904cb1
commit
4cd3611251
1 changed files with 4 additions and 2 deletions
|
|
@ -86,7 +86,7 @@ export function createThing({
|
|||
$thing.setAttribute("data-n", n);
|
||||
$thing.setAttribute("data-path", path);
|
||||
$thing.classList.add("view-" + view);
|
||||
$time.textContent = formatTime(new Date(time));
|
||||
$time.textContent = formatTime(time);
|
||||
$img.setAttribute("src", (type === "file" ? IMAGE.FILE : IMAGE.FOLDER));
|
||||
$label.textContent = name;
|
||||
|
||||
|
|
@ -192,7 +192,9 @@ export function createThing({
|
|||
return $thing;
|
||||
}
|
||||
|
||||
function formatTime(date) {
|
||||
function formatTime(unixTime) {
|
||||
if (unixTime <= 0) return "";
|
||||
const date = new Date(unixTime);
|
||||
if (!date) return "";
|
||||
// Intl.DateTimeFormat is slow and in the hot path, so
|
||||
// let's render date manually if possible
|
||||
|
|
|
|||
Loading…
Reference in a new issue