2022-07-22 00:48:31 +02:00
|
|
|
function prettyTime(date: Date) {
|
|
|
|
const hour = date
|
|
|
|
.getHours()
|
|
|
|
.toLocaleString("fr-FR", { minimumIntegerDigits: 2 })
|
|
|
|
const minute = date
|
|
|
|
.getMinutes()
|
|
|
|
.toLocaleString("fr-FR", { minimumIntegerDigits: 2 })
|
|
|
|
return `${hour}h${minute}`
|
|
|
|
}
|
|
|
|
|
2022-07-13 01:02:23 +02:00
|
|
|
export const prettyDate = {
|
|
|
|
full(date: Date | string) {
|
|
|
|
const objDate = typeof date === "string" ? new Date(date) : date
|
|
|
|
const strDate = objDate.toLocaleDateString("fr-FR", {
|
|
|
|
weekday: "long",
|
|
|
|
year: "numeric",
|
|
|
|
month: "long",
|
|
|
|
day: "numeric",
|
|
|
|
})
|
2022-07-22 00:48:31 +02:00
|
|
|
const time = prettyTime(objDate)
|
|
|
|
return `${strDate}, ${time}`
|
|
|
|
},
|
|
|
|
short(date: Date | string) {
|
|
|
|
const objDate = typeof date === "string" ? new Date(date) : date
|
|
|
|
const strDate = objDate.toLocaleDateString("fr-FR", {
|
|
|
|
weekday: "narrow",
|
|
|
|
month: "numeric",
|
|
|
|
day: "numeric",
|
|
|
|
})
|
|
|
|
const time = prettyTime(objDate)
|
2022-07-13 01:02:23 +02:00
|
|
|
return `${strDate}, ${time}`
|
|
|
|
},
|
|
|
|
}
|