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

Extract recurrence dates - why won't this work?

3 Answers 52 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Paul Nascimento
Top achievements
Rank 1
Paul Nascimento asked on 19 May 2010, 10:43 PM
I'm trying to take a recurrence rule string that the scheduler put in my DB, and extract a list of dates from it. I found an example, but it doesn't work. rrule always returns null. Ultimately I just need a list of dates. Thanks

//this was generated by the scheduler, and I coped it to here from the DB 
string ruleString = "DTSTART:20100504T000000Z  DTEND:20100505T000000Z  RRULE:FREQ=WEEKLY;COUNT=2;INTERVAL=1;BYDAY=TU";  
 
RecurrenceRule rrule; 
RecurrenceRule.TryParse(ruleString, out rrule); 
if (rrule == null
    return
 
DateTime test; 
foreach (DateTime occurrence in rrule.Occurrences) 
    //do something with each date... 
 
 

3 Answers, 1 is accepted

Sort by
0
Accepted
T. Tsonev
Telerik team
answered on 21 May 2010, 03:58 PM
Hi Paul,

The fields must be on new lines in order for the parsing to work. For example:

string ruleString = "DTSTART:20100504T000000Z\r\nDTEND:20100505T000000Z\r\nRRULE:FREQ=WEEKLY;COUNT=2;INTERVAL=1;BYDAY=TU";

I hope this helps.

All the best,
Tsvetomir Tsonev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Paul Nascimento
Top achievements
Rank 1
answered on 21 May 2010, 04:08 PM
Well that got me 2 lines further : )

Now it's giving an error at 

RecurrenceRule.TryParse(ruleString, out rrule);

It's giving the old "Object reference not set to an instance of an object" error.

Should I have done something other than just "RecurrenceRule rrule;" ? Should I have initialized it somehow?
0
Paul Nascimento
Top achievements
Rank 1
answered on 21 May 2010, 06:34 PM
Never mind, I had a typo in my code.
I put \r\r in for one of my new lines instead of \r\n. It works fine now.

Thanks again.
Tags
Scheduler
Asked by
Paul Nascimento
Top achievements
Rank 1
Answers by
T. Tsonev
Telerik team
Paul Nascimento
Top achievements
Rank 1
Share this question
or