jkbrzt / rrule

JavaScript library for working with recurrence rules for calendar dates as defined in the iCalendar RFC and more.
https://jkbrzt.github.io/rrule
Other
3.27k stars 507 forks source link

Between function returning no results #531

Open clepsydraweb opened 2 years ago

clepsydraweb commented 2 years ago

Good morning to everyone.

I'm having a really hard time understanding why the between function sometimes doesn't work as expected. I'm working with different timezones, but for now I don't need to support them, I just want that the between function returns the recurrencies.

The rrule string: DTSTART:20210703T090000Z; RRULE:FREQ=MINUTELY;UNTIL=20220704T121500Z;BYDAY=MO,TU,WE,TH,FR,SU;WKST=MO;BYHOUR=9,10,11,12;INTERVAL=15

The time span I'm trying to test: rrule.between(new Date('Sun Jul 03 2022 17:00:00 GMT+0800 (China Standard Time)'),new Date('Sun Jul 03 2022 20:15:00 GMT+0800 (China Standard Time)'))

This isn't giving me any results, even if it should.

But if I change the DTSTART from 2021 to 2022 (DTSTART:20220703T090000Z; RRULE:FREQ=MINUTELY;UNTIL=20220704T121500Z;BYDAY=MO,TU,WE,TH,FR,SU;WKST=MO;BYHOUR=9,10,11,12;INTERVAL=15 keeping the exact date, while other dates do not work anymore) it returns me the results.

[ "2022-07-03T09:15:00.000Z", "2022-07-03T09:30:00.000Z", "2022-07-03T09:45:00.000Z", "2022-07-03T10:00:00.000Z", "2022-07-03T10:15:00.000Z", "2022-07-03T10:30:00.000Z", "2022-07-03T10:45:00.000Z", "2022-07-03T11:00:00.000Z", "2022-07-03T11:15:00.000Z", "2022-07-03T11:30:00.000Z", "2022-07-03T11:45:00.000Z", "2022-07-03T12:00:00.000Z" ]

Even changing timezones, using Date.UTC, etc. etc., doesn't change anything, problems still happen: between function isn't always returning correct array of elements.

I can't get it, it looks like a bug to me, but can't find other people complaining about it, so maybe it's just a simple thing that I'm missing somewhere?

I'm testing this with anything beside the rrule.js (no other plugins, libraries, etc. etc., just this).

Thank you in advance for any help given!

keithjgrant commented 1 year ago

I'm having this issue as well. between() seems to return no results prior to the current date/time. Even if the rrule starts well in the past, I can only get results from between() if the end date is in the future. It's almost as if "now" is used as the begin date/time, and anything prior to that is ignored.

keithjgrant commented 1 year ago

okay, after further experimentation, i think I can work around the issue.

I'm working with a ruleSet. the start date needs to be set for each rrule in the set in order for between to work, otherwise it seems to ignore my begin date and uses the current time instead. (this might be the expected behavior, as the python library behaves similarly: https://stackoverflow.com/questions/618910/dateutil-rrule-rrule-between-gives-only-dates-after-now)