13 lines
373 B
TypeScript
13 lines
373 B
TypeScript
|
|
export default function formatTime(d: string | Date | null | undefined): string {
|
|
if (!d) return "Heure inconnue";
|
|
|
|
const date = d instanceof Date ? d : new Date(d);
|
|
if (isNaN(date.getTime())) return "Heure invalide";
|
|
|
|
const hh = String(date.getUTCHours()).padStart(2, "0");
|
|
const min = String(date.getUTCMinutes()).padStart(2, "0");
|
|
|
|
return `${hh}:${min}`;
|
|
}
|