Skip to content

Commit

Permalink
Support DATE value for EXDATE
Browse files Browse the repository at this point in the history
  • Loading branch information
stshort committed Feb 8, 2022
1 parent c75a328 commit 4762611
Show file tree
Hide file tree
Showing 4 changed files with 273 additions and 267 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
"style-loader": "^2.0.0",
"stylelint": "^13.6.1",
"ts-loader": "^7.0.4",
"typescript": "^4.3.2",
"typescript": "4.3.2",
"webpack": "^5.38.1",
"webpack-cli": "^4.1.0"
}
Expand Down
11 changes: 8 additions & 3 deletions packages/icalendar/src/ical-expander/IcalExpander.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,14 @@ export class IcalExpander {
(!before || startTime <= before.getTime());
}

function getTimes(eventOrOccurrence) {
const startTime = eventOrOccurrence.startDate.toJSDate().getTime();
let endTime = eventOrOccurrence.endDate.toJSDate().getTime();
function getTimes(eventOrOccurrence, onlyDate) {
const start = eventOrOccurrence.startDate.toJSDate();
const end = eventOrOccurrence.endDate.toJSDate();

// If we are only checking the date portions, return new date objects that contain no time fields. This is important
// for omitting exclusion dates where VALUE=DATE, i.e. EXDATE;VALUE=DATE:20220210/P1D
const startTime = onlyDate ? new Date(start.getFullYear(), start.getMonth(), start.getDate()).getTime() : start.getTime();
let endTime = onlyDate ? new Date(start.getFullYear(), start.getMonth(), start.getDate()).getTime() : end.getTime();

// If it is an all day event, the end date is set to 00:00 of the next day
// So we need to make it be 23:59:59 to compare correctly with the given range
Expand Down
1 change: 1 addition & 0 deletions packages/icalendar/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ function buildNonDateProps(iCalEvent: ICAL.Event): EventInput {
location: iCalEvent.location,
organizer: iCalEvent.organizer,
description: iCalEvent.description,
uid: iCalEvent.uid,
},
}
}
Expand Down
Loading

0 comments on commit 4762611

Please sign in to comment.