20 lines
569 B
TypeScript
20 lines
569 B
TypeScript
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",
|
|
})
|
|
const hour = objDate
|
|
.getHours()
|
|
.toLocaleString("fr-FR", { minimumIntegerDigits: 2 })
|
|
const minute = objDate
|
|
.getMinutes()
|
|
.toLocaleString("fr-FR", { minimumIntegerDigits: 2 })
|
|
const time = `${hour}h${minute}`
|
|
|
|
return `${strDate}, ${time}`
|
|
},
|
|
}
|