Single- OneTime Occurence iCalendarPattern?


#1

If I have a single, one time date.... is there a way to represent that with a pattern?

Maybe this?

DTSTART:20040101T103000
RRULE:FREQ=DAILY;COUNT=1


#2

Yes this pattern will work for a single occurrence.


#3

Romank,

You may want to check this. I think there is a bug with the "Count=1".

I used

DTSTART:19770113T010000
RRULE:FREQ=DAILY;COUNT=1

Which, according to our discussion would give 1 instance, on Jan 13th, 1977.

The counter I set, was over 10,000 entries (aka, .GenerateOccurences).

I had to revert to using the "Until" date of the same date.

DTSTART:19770113T010000
RRULE:FREQ=DAILY;UNTIL=19770113T000000Z

It did this behavior, if I created the rules programatically, or using a hardcoded iCalendarExpression.

C# code:

DateTime occurenceDate = new DateTime(1977, 1, 13);

RecurrencePattern p = new RecurrencePattern();

RecurrenceRule r = new RecurrenceRule();

p.StartDate = occurenceDate;

r.Until = occurenceDate; //see note below

r.Frequency = Aspose.iCalendar.Frequency.Daily;

//r.Count = 1; // this is the issue, uncomment this ... and comment out r.Until (above) .... OR leave r.Until intact...

p.RRules.Add (r);

string ical = p.ToiCalendar();

System.DateTime[] dts = FindDates(ical);

//--------------------------

I have a "FindDates" routine also:

private static System.DateTime[] FindDates(string calendarExpression)

{

RecurrencePattern p = new RecurrencePattern(calendarExpression);

foreach(RecurrenceRule r in p.RRules)

{

Console.WriteLine(r.Until);

DateCollection recurrenceDates = p.GenerateOccurrences();

if (recurrenceDates.Count > 100) // this number is ~alot

{

Console.WriteLine("");

}

else

{

Console.WriteLine("");

}

System.DateTime[] dates = (DateTime[]) recurrenceDates.ToArray(typeof(DateTime));

return dates;

}