starshard/peafowl
Template
1
Fork 0
mirror of https://github.com/starshardstudio/peafowl.git synced 2024-11-22 04:54:19 +00:00
peafowl/_utils/date.ts
2024-07-01 16:44:56 +02:00

11 lines
469 B
TypeScript

import { GlobalData } from "./site.ts";
export function formatDateIso(date?: Date): string {
if(date === undefined) return ""
date = new Date(date)
return `${date.getFullYear().toString().padStart(4, "0")}-${(date.getMonth() + 1).toString().padStart(2, "0")}-${date.getDate().toString().padStart(2, "0")}`
}
export function compareDate(a: GlobalData, b: GlobalData): number {
return new Date(a.date ?? 0).getTime() - new Date(b.date ?? 0).getTime()
}