Free Support Forum - aspose.com

Weekdays only?

How do I specify that the GenerateOccurrences return only weekdays in the resulting DateArray? Seems like I should be able to do this, rather than run through the DateArray to check every returned date to make sure it’s not on a weekend day, right?

Hi,

If I understand correctly you just want to repeat your event on every weekday, right?
Because this pattern is repeated every week (or every Nth week), you need to use Aspose.Recurrence.Weekly class.

//Repeat every week.
Weekly recur = new Weekly(1);
recur.StartDate = new DateTime(2003, 4, 15);

//Set which days of week you want the event to happen on.
recur.DaysOfWeek.SetDayOn(DayOfWeek.Monday, true);
recur.DaysOfWeek.SetDayOn(DayOfWeek.Tuesday, true);
recur.DaysOfWeek.SetDayOn(DayOfWeek.Wednesday, true);
recur.DaysOfWeek.SetDayOn(DayOfWeek.Thursday, true);
recur.DaysOfWeek.SetDayOn(DayOfWeek.Friday, true);

DateArray occurrences = new DateArray();
//This will generate events only on weekdays.
recur.GenerateOccurrences(rangeStartDate, rangeEndDate, occurrences);


See Aspose.Recurrence.Weekly for more details.

How do you filter by weekdays only when using Daily? PLEASE DISREGARD! I dumped the Daily and went with Weekly only. Thanks, D-