Time zone not accounted for in recurrence rule Occurrences

5 posts, 0 answers
  1. Derek
    Derek avatar
    6 posts
    Member since:
    Jul 2012

    Posted 15 Nov 2013 Link to this post

    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.
  2. Boyan Dimitrov
    Admin
    Boyan Dimitrov avatar
    1746 posts

    Posted 20 Nov 2013 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Derek
    Derek avatar
    6 posts
    Member since:
    Jul 2012

    Posted 20 Nov 2013 Link to this post

    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.
  5. Derek
    Derek avatar
    6 posts
    Member since:
    Jul 2012

    Posted 20 Nov 2013 Link to this post

    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. 
  6. Derek
    Derek avatar
    6 posts
    Member since:
    Jul 2012

    Posted 21 Nov 2013 Link to this post

    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. 
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017