Skip to content
This repository has been archived by the owner on Jan 3, 2024. It is now read-only.

Commit

Permalink
fix(calendar): start iCalendar on Monday
Browse files Browse the repository at this point in the history
  • Loading branch information
maelgangloff committed Sep 22, 2021
1 parent 5394757 commit 1ad7b76
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 409 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "kdecole-api",
"version": "1.2.6",
"version": "1.2.7",
"main": "dist/Kdecole.js",
"types": "types/Kdecole.d.ts",
"bin": {
Expand Down
4 changes: 3 additions & 1 deletion src/entities/Calendar/Calendrier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ export default class Calendrier {

const numberOfWeek = (d1: Date, d2: Date): number => ((d1.getTime() - d2.getTime()) / (7 * 24 * 60 * 60 * 1000))

const getMonday = (d: Date): Date => new Date(new Date(d.setDate((d.getDate() - d.getDay()) + (d.getDay() === 0 ? -6 : 1))).setHours(0, 0, 0, 0))

return `BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//kdecole-api//ical//EN
Expand All @@ -70,7 +72,7 @@ TZID:Europe/Paris
NAME:${name}
X-WR-CALNAME:${name}
` + this.listeJourCdt
.filter(jour => this.currentDate <= jour.date && numberOfWeek(jour.date, this.currentDate) < weeks)
.filter(jour => getMonday(this.currentDate) <= jour.date && numberOfWeek(jour.date, this.currentDate) < weeks)
.map(jour => jour.listeSeances).flat()
.filter(seance => seance.flagActif)
.reduce((acc, seance) =>
Expand Down
Loading

0 comments on commit 1ad7b76

Please sign in to comment.