Skip to content

Commit

Permalink
Use localstart and end to avoid issue we were having
Browse files Browse the repository at this point in the history
  • Loading branch information
muness committed Feb 10, 2024
1 parent 459597a commit 0c01f1b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/icalUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ function adjustDateToOriginalTimezone(originalDate: Date, currentDate: Date, tzi
}

export function filterMatchingEvents(icsArray: any[], dayToMatch: string) {
const localStartOfDay = moment(dayToMatch).startOf('day');
const localEndOfDay = moment(dayToMatch).endOf('day');

return icsArray.reduce((matchingEvents, event) => {
var hasRecurrenceOverride = false
Expand All @@ -60,7 +62,7 @@ export function filterMatchingEvents(icsArray: any[], dayToMatch: string) {
const utcStartOfDay = moment(dayToMatch).utc().startOf('day').toDate();
const utcEndOfDay = moment(dayToMatch).utc().endOf('day').toDate();

event.rrule.between(utcStartOfDay, utcEndOfDay).forEach(date => {
event.rrule.between(localStartOfDay.toDate(), localEndOfDay.toDate()).forEach(date => {

// now the date is in the local timezone, so we need to apply the offset to get it back to UTC
const offset = moment(date).utcOffset();
Expand Down

0 comments on commit 0c01f1b

Please sign in to comment.