Skip to content

Commit 0c01f1b

Browse files
committed
Use localstart and end to avoid issue we were having
1 parent 459597a commit 0c01f1b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/icalUtils.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ function adjustDateToOriginalTimezone(originalDate: Date, currentDate: Date, tzi
3939
}
4040

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

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

63-
event.rrule.between(utcStartOfDay, utcEndOfDay).forEach(date => {
65+
event.rrule.between(localStartOfDay.toDate(), localEndOfDay.toDate()).forEach(date => {
6466

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

0 commit comments

Comments
 (0)