Formatage des dates dans l'interface

This commit is contained in:
2020-10-01 11:44:29 +02:00
parent 11f54ab66e
commit 61eacefd6c
4 changed files with 26 additions and 11 deletions

View File

@ -1,4 +1,16 @@
export function asDate(d: string|Date): Date {
if (typeof d === 'string') return new Date(d);
return d;
}
const intl = Intl.DateTimeFormat(navigator.language, {
weekday: 'long',
month: 'short',
day: 'numeric',
hour: 'numeric', minute: 'numeric', second: 'numeric',
});
export function formatDate(d: Date|string): string {
d = asDate(d);
return intl.format(d);
}