From e270bb7071d94f588319533995b1ccf63eac13f0 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 29 Nov 2022 15:01:16 +0000 Subject: [PATCH] Update generate-packages-index.ts --- scripts/generate-packages-index.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/scripts/generate-packages-index.ts b/scripts/generate-packages-index.ts index e6d0723..a74adbc 100755 --- a/scripts/generate-packages-index.ts +++ b/scripts/generate-packages-index.ts @@ -101,6 +101,14 @@ function humanFileSize(bytes: number, si = false, dp = 1) { return bytes.toFixed(dp) + ' ' + units[u]; } +const dateTimeOptions = { + year: "numeric", + month: "short", + day: "2-digit", + hour: "2-digit", + minute: "numeric", +}; + function indexLayout(prefix: string, files: _Object[], dirs: string[]): string { const rows: [link: string, name: string, size?: number, date?: Date][] = []; @@ -138,13 +146,7 @@ function indexLayout(prefix: string, files: _Object[], dirs: string[]): string { ${rows.map(([link, name, size, date]) => ` ${name} ${size ? humanFileSize(size) : "-"} - ${date?.toLocaleString("en-GB", { - year: "numeric", - month: "short", - day: "2-digit", - hour: "2-digit", - minute: "numeric", - }) ?? "-"} + ${date?.toLocaleString("en-GB", dateTimeOptions) ?? "-"} `).join("")}