ScheduleWidget Tutorial 2
In the last post I introduced ScheduleWidget and went through a simple exercise of creating a recurring schedule based on the Critical Mass bicycle ride. I'm going to assume you've run through that exercise. Critical Mass occurs the last Friday of every month. But let's suppose that there's a second ride called Fair Weather Critical Mass (or FW for short). FW still occurs the last Friday of every month but its riders don't really like to ride in cold temperatures. So they start riding in May and then wrap it up in September.
So our event can be described as "FW occurs the last Friday of every month between May and September." This is modeled in ScheduleWidget with a RangeInYear object that must be created with the Event itself:
var aEvent = new Event() { ID = 1, Title = "Fair Weather Critical Mass", FrequencyTypeOptions = FrequencyTypeEnum.Monthly, MonthlyIntervalOptions = MonthlyIntervalEnum.Last, DaysOfWeekOptions = DayOfWeekEnum.Fri, RangeInYear = new RangeInYear() { StartMonth = 5, EndMonth = 9 }, };
Now when we call our schedule to get the occurrences for the next year we get this list:
Pretty cool. In addition to the Occurrences method the Schedule class supports three other methods:
- IsOccurring
- NextOccurrence
- PreviousOccurrence
The first two were described by Fowler in his white paper and the last one I added for the sake of completeness. :) In the next blog post I'll describe them further.

My name is James Still and I'm a seasoned software developer living and working in Oregon USA. I'm an avid cyclist, backpacker, reader, stargazer, and I pick at the guitar from time to time.