This is a migrated thread and some comments may be shown as answers.

Time zone not accounted for in recurrence rule Occurrences

4 Answers 126 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Derek
Top achievements
Rank 1
Derek asked on 15 Nov 2013, 03:19 PM
This is a bit of an edge case, so I'll need to explain.

Say you have a scheduler with its time zone set to Central Standard Time (UTC -6) and you create a scheduled appointment. The schedule is set to occur yearly, every first Monday of December. If you choose a start time of 7pm or later, the appointments appear on the day before they should be scheduled.

Here's what I think is happening: The recurrence rule first figures out what dates the first Monday of December are for the next few years. It then converts the time into UTC to store in the database. So 7pm would become 1am. When these appointments are shown on the schedule, it then tries to convert it back to Central Standard Time, however since it's going back before midnight, the day also gets pushed back.

Ultimately the problem is that when the recurrence rule is figuring out the Occurrences property, it first figures out the dates, and THEN adds the converted time, rather than converting the entire date for the time zone.

If this is a known problem or there's any kind of workaround, please let me know. Thanks.

4 Answers, 1 is accepted

Sort by
0
Boyan Dimitrov
Telerik team
answered on 20 Nov 2013, 04:52 PM
Hello,

I would like to clarify that I am not able to replicate the described issue when following the steps below. Please find attached a sample page containing RadScheduler populated by XML file. The appointment starts at 7 PM every first Monday of December and the recurrence frequency is set to yearly. Could you please try to replicate this problem with that project and clarify what exactly is different in your scenario?


Regards,
Boyan Dimitrov
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
Derek
Top achievements
Rank 1
answered on 20 Nov 2013, 05:42 PM
I've replicated the issue using your example. The problem seems to be with the RecurrenceRule.TryParse() method. I added this event to your example:

protected void RadScheduler1_AppointmentInsert(object sender, AppointmentInsertEventArgs e)
{
    RecurrenceRule rrule;
    RecurrenceRule.TryParse(e.Appointment.RecurrenceRule, out rrule);
 
    var blah = e.Appointment;
 
}

Now if you look at the Occurrences property of the rrule that's created, it converts the times to UTC but keeps the days the same. For example, if I schedule the first day as 12/18 7pm, it converts the first occurrence to 12/18 1am. If you save this to the database it will be incorrect when showing it again in the scheduler because when it converts it back to Central Standard Time it converts the entire date and time to 12/17 7pm.

I should note that it's a requirement of my project to save each occurrence to a database. I'm not able to use a master occurrence's schedule to generate the rest of the appointments on the client.
0
Derek
Top achievements
Rank 1
answered on 20 Nov 2013, 06:43 PM
I can work around this particular instance by manually advancing the date, however the RecurrenceRule.TryParse method seems to be very inconsistent with the RecurrenceRule it creates.

It also fails with weekly recurrence. If I create a Weekly recurring schedule starting at 12/5 8pm with an end date of 12/19, I should get three occurrences, 12/5, 12/12, and 12/19. But the RecurrenceRule does not include the 12/5 occurrence. 
0
Derek
Top achievements
Rank 1
answered on 21 Nov 2013, 09:17 PM
I fixed the problem by changing how the recurrence rule text is created in my custom advanced schedule form. Instead of using UTC dates in the recurrence rule, I leave them in the local timezone. When the recurrence rule is parsed again from this text, the Occurrences property is correct (though everything is still in the local timezone). I then convert the dates to UTC before saving to the database.

I also had to do a manual check for if the appointment started at midnight, because the Occurrences property was still adding an extra occurrence after the RecursUtil date in that case.

This is just a heads up that anyone using the stock advanced schedule form will not be getting the correct occurrences if trying to parse the recurrence rule manually. 
Tags
Scheduler
Asked by
Derek
Top achievements
Rank 1
Answers by
Boyan Dimitrov
Telerik team
Derek
Top achievements
Rank 1
Share this question
or