Files
lara-bermite/resources/js/customPrototypes.ts
2023-09-24 11:19:58 +02:00

16 lines
410 B
TypeScript

const weekDays = ['lundi', 'mardi', 'mercredi', 'jeudi', 'vendredi', 'samedi', 'dimanche']
interface Date {
getWeekDay(): string,
toSQLDate(): string,
}
Date.prototype.toSQLDate = function (): string {
return (new Date(this)).toISOString().split('T')[0]
}
Date.prototype.getWeekDay = function () {
const dayIndex = this.getDay() === 0 ? 6 : this.getDay() - 1
return weekDays[dayIndex]
}