本文整理汇总了C#中iCalendar.GetOccurrences方法的典型用法代码示例。如果您正苦于以下问题:C# iCalendar.GetOccurrences方法的具体用法?C# iCalendar.GetOccurrences怎么用?C# iCalendar.GetOccurrences使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类iCalendar
的用法示例。
在下文中一共展示了iCalendar.GetOccurrences方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Bug3414862
public void Bug3414862()
{
IICalendar iCal = new iCalendar();
Event evt = iCal.Create<Event>();
RecurrencePattern rPattern = new RecurrencePattern();
rPattern.Frequency = FrequencyType.Weekly;
FrequencyOccurrence frequencyOccurrence = FrequencyOccurrence.First;
rPattern.ByDay.Add(new WeekDay(DayOfWeek.Wednesday, frequencyOccurrence));
DateTime startDateTime = new DateTime(2011, 1, 5, 13, 0, 0);
DateTime endDateTime = new DateTime(2013, 4, 3, 13, 45, 0);
evt.Start = new iCalDateTime(startDateTime);
evt.Duration = new TimeSpan(0, 45, 0);
rPattern.Until = endDateTime;
evt.RecurrenceRules.Add(rPattern);
DateTime thruDateTime = new DateTime(2013, 3, 6);
IList<Occurrence> occurrences = iCal.GetOccurrences(startDateTime, thruDateTime.Date.AddDays(1).AddSeconds(-1));
// There should be exactly 114 occurrences
Assert.AreEqual(114, occurrences.Count);
// The last occurrence should be on march 6th
Assert.AreEqual(new DateTime(2013, 3, 6), occurrences.Last().Period.StartTime.Date);
}