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.28k stars 510 forks source link

RRule dates in .all() are wrong #466

Open 8shaks opened 3 years ago

8shaks commented 3 years ago

I'm trying to set a recurring rule that happens on the wednesday of every week. My rrule string is: DTSTART:20210626T040000Z\nRRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=WE

However if I do console.log(RRule.fromString("DTSTART:20210626T040000Z\nRRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=WE").all()[19]);, I notice the day is a Tuesday instead of a Wednesday, and this issue repeats quite a bit. When I adjust the rrule string to :

"RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=WE"

This issue dissapears, so it seems like a bug with RRule interprets dtstart. My rrule version is 2.6.8, my time zone is EST

spacegangster commented 3 years ago

@8shaks, take into account that your generated dates are in UTC. So maybe in EST they will be still Tuesday, because it may be UTC-5 (perhaps in winter). I've generated an array of dates for your RRule and they all are on Wednesday for me, as I'm in UTC+3.

You need Luxon to support RRule adjustment for timezones. I'm still figuring it out myself on 2.6.6, I think I had some issue with Luxon on 2.6.8, but even on 2.6.6 I'm still playing around.

spacegangster commented 2 years ago

@8shaks Please also read https://github.com/jakubroztocil/rrule#important-use-utc-dates