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

[Solved] Programmatic Recurrence Rule Exception Yields Wrong Time

2 Answers 236 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Colin Teal
Top achievements
Rank 1
Colin Teal asked on 16 Jan 2010, 04:23 AM

I have come across an issue in which the exceptions for a given recurrence rule are not being programmatically generated properly.  The date portion is correct (that is, the date at which the exception is supposed to occur), but the time is wrong.  I'm likely doing something wrong (as RadScheduler can figure out the correct time), but I wasn't able to track down a solution.

The initial recurrence rule (programmatically created from a database record) is this:

DTSTART:20100115T090000Z
DTEND:20100115T170000Z
RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=MO,WE,FR

When I go to add an exception for this weekly recurring event on 1/20/2009, RadScheduler gives me this new rule on the OnAppointmentUpdated event:

DTSTART:20100115T090000Z
DTEND:20100115T170000Z
RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=MO,WE,FR
EXDATE:20100120T090000Z

Obviously, I trust that RadScheduler is doing the right thing here.

In order to capture exceptions (in this case a delete), I insert a new row into my table with the exception start date 1/20/2009 9:00 a.m., and an end date 1/20/2009 5:00 p.m. (to maintain the parent event duration), with a foreign key to the parent event.  When I generate the new recurrence rule for the parent event, I find the exception and attempt to add it to the recurrence rule programmatically using the exception start DateTime (in this case, the one mentioned above in bold)...

a la...

rule.Exceptions.Add(exception.StartDate); 

This is the result immediately following the call above:

DTSTART:20100115T090000Z
DTEND:20100115T170000Z
RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=MO,WE,FR
EXDATE:20100120T170000Z

They are identical apart from the exception date time.  I don't know why the end time for the relation is being used on the exception.  I have stepped through my code to verify that the DateTime object being used to generate the exception is indeed correct (and it is).  The recurrence rule should have no notion of the exception end time unless it is being inherited from the recurrence start DateTime.

Just in case this is helpful, I am using the ASP.NET Ajax Q2 2009 version of the Telerik controls.

Am I missing something obvious?

2 Answers, 1 is accepted

Sort by
0
Accepted
T. Tsonev
Telerik team
answered on 18 Jan 2010, 09:09 AM
Hello Colin,

Thank you for providing such detailed description of the problem.

The recurrence exceptions are stored in UTC (with the Z suffix) and RadScheduler will try to internally convert them by calling ToUniversalTime before storing the date.

In order to store the date unchanged you need to pass it in as UTC. You can use the following method:
var exceptionStartDateUtc = DateTime.SpecifyKind(exception.StartDate, DateTimeKind.Utc)

SpecifyKind will only change the date type without actually changing the value.

I hope this helps.

Sincerely yours,
Tsvetomir Tsonev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Colin Teal
Top achievements
Rank 1
answered on 18 Jan 2010, 10:01 PM
That did the trick!  Thank you so much for the help!
Tags
Scheduler
Asked by
Colin Teal
Top achievements
Rank 1
Answers by
T. Tsonev
Telerik team
Colin Teal
Top achievements
Rank 1
Share this question
or