I'm using rrule to create and store events in my database.
All was working until I found that my recurring events had an one hour difference past the 31st march.
In France, it's the day when we do a daylight saving time change.
Actually, my events are stored in a mongo database, with the start date and the duration of the event, + the eventuals rrules (all events aren't recurring events) like this :
{
"_id" : ObjectId("5c8e4706703df43859aabbe7"),
"duration" : 2879,
"type" : "unavailability",
"title" : "Weekend",
"description" : "C'est le weekend",
"rrules" : [
{
"until" : ISODate("2021-03-22T23:00:00.000Z"),
"dtstart" : ISODate("2019-03-11T23:00:00.000Z"),
"byweekday" : [
{
"weekday" : 5
},
{
"weekday" : 6
}
],
"interval" : 1,
"freq" : 2
}
],
"__v" : 0
}
When the frontend search for a date in the calendar, it will search with this args :
?from=2019-03-10T23:00:00.000Z&to=2019-03-17T23:00:00.000Z
It works well with this date, because no daylight savings are occuring in between. If I have this object :
normalizedDates = { from: 2019-03-10T23:00:00.000Z, to: 2019-03-17T23:00:00.000Z }
and this rule :
{ until: 2021-03-22T23:00:00.000Z,
dtstart: 2019-03-11T23:00:00.000Z,
byweekday: [ { weekday: 5 }, { weekday: 6 } ],
interval: 1,
freq: 2 }
Running :
const recurringDays = rruleSet.between(normalizedDates.from, normalizedDates.to)
shows, indeed :
recurringDays [ 2019-03-23T23:00:00.000Z ]
But if y use :
normalizedDates = { from: 2019-03-31T22:00:00.000Z, to: 2019-04-07T22:00:00.000Z }
Rrules returns :
recurringDays [ 2019-03-31T23:00:00.000Z, 2019-04-06T23:00:00.000Z ]
while I'm expecting :
recurringDays [ 2019-04-06T22:00:00.000Z ]
Do you know how I could handle this ?