Add a {time} template helper, reuse timestamp code from Quick Note as a niceTime (#555)

niceTime helper
This commit is contained in:
johnl
2023-11-03 12:04:51 +01:00
committed by GitHub
parent e0b6fbed3e
commit 0e2a802bbd
3 changed files with 12 additions and 5 deletions
+7
View File
@@ -9,3 +9,10 @@ export function niceDate(d: Date): string {
return d.getFullYear() + "-" + pad(d.getMonth() + 1) + "-" + pad(d.getDate());
}
export function niceTime(d: Date): string {
const isoDate = d.toISOString();
let [date, time] = isoDate.split("T");
// hh:mm:ss
return time.split(".")[0];
}