public void SkippedOccurrenceOnWeeklyPattern() { const int evaluationsCount = 1000; var eventStart = new CalDateTime(new DateTime(2016, 1, 1, 10, 0, 0, DateTimeKind.Utc)); var eventEnd = new CalDateTime(new DateTime(2016, 1, 1, 11, 0, 0, DateTimeKind.Utc)); var vEvent = new CalendarEvent { DtStart = eventStart, DtEnd = eventEnd, }; var pattern = new RecurrencePattern { Frequency = FrequencyType.Weekly, ByDay = new List <WeekDay> { new WeekDay(DayOfWeek.Friday) } }; vEvent.RecurrenceRules.Add(pattern); var calendar = new Calendar(); calendar.Events.Add(vEvent); var intervalStart = eventStart; var intervalEnd = intervalStart.AddDays(7 * evaluationsCount); var occurrences = RecurrenceUtil.GetOccurrences( recurrable: vEvent, periodStart: intervalStart, periodEnd: intervalEnd, includeReferenceDateInResults: false); var occurrenceSet = new HashSet <IDateTime>(occurrences.Select(o => o.Period.StartTime)); Assert.AreEqual(evaluationsCount, occurrenceSet.Count); for (var currentOccurrence = intervalStart; currentOccurrence.CompareTo(intervalEnd) < 0; currentOccurrence = (CalDateTime)currentOccurrence.AddDays(7)) { var contains = occurrenceSet.Contains(currentOccurrence); Assert.IsTrue(contains, $"Collection does not contain {currentOccurrence}, but it is a {currentOccurrence.DayOfWeek}"); } }
public void SkippedOccurrenceOnWeeklyPattern() { const int evaluationsCount = 1000; var eventStart = new CalDateTime(new DateTime(2016, 1, 1, 10, 0, 0, DateTimeKind.Utc)); var eventEnd = new CalDateTime(new DateTime(2016, 1, 1, 11, 0, 0, DateTimeKind.Utc)); var vEvent = new CalendarEvent { DtStart = eventStart, DtEnd = eventEnd, }; var pattern = new RecurrencePattern { Frequency = FrequencyType.Weekly, ByDay = new List <WeekDay> { new WeekDay(DayOfWeek.Friday) } }; vEvent.RecurrenceRules.Add(pattern); var calendar = new Calendar(); calendar.Events.Add(vEvent); var intervalStart = eventStart; var intervalEnd = intervalStart.AddDays(7 * evaluationsCount); var occurrences = RecurrenceUtil.GetOccurrences(vEvent, intervalStart, intervalEnd, false) .Select(o => o.Period.StartTime) .OrderBy(dt => dt) .ToList(); Assert.AreEqual(evaluationsCount, occurrences.Count); for (var currentOccurrence = intervalStart.AsUtc; currentOccurrence.CompareTo(intervalEnd.AsUtc) < 0; currentOccurrence = currentOccurrence.AddDays(7)) { Assert.IsTrue(occurrences.Contains(new CalDateTime(currentOccurrence)), $"Collection does not contain {currentOccurrence}, but it is a {currentOccurrence.DayOfWeek}"); } }
public virtual HashSet <Occurrence> GetOccurrences(IDateTime startTime, IDateTime endTime) { return(RecurrenceUtil.GetOccurrences(this, startTime, endTime, EvaluationIncludesReferenceDate)); }
public virtual HashSet <Occurrence> GetOccurrences(DateTime startTime, DateTime endTime) { return(RecurrenceUtil.GetOccurrences(this, new CalDateTime(startTime), new CalDateTime(endTime), EvaluationIncludesReferenceDate)); }
public virtual HashSet <Occurrence> GetOccurrences(DateTime dt) { return(RecurrenceUtil.GetOccurrences(this, new CalDateTime(dt), EvaluationIncludesReferenceDate)); }
public virtual HashSet <Occurrence> GetOccurrences(DateTime startTime, DateTime endTime) { return(RecurrenceUtil.GetOccurrences(this, new CalDateTime(startTime), new CalDateTime(endTime), true)); }
public virtual HashSet <Occurrence> GetOccurrences(IDateTime startTime, IDateTime endTime) { return(RecurrenceUtil.GetOccurrences(this, startTime, endTime, true)); }
public virtual HashSet <Occurrence> GetOccurrences(DateTime dt) { return(RecurrenceUtil.GetOccurrences(this, new CalDateTime(dt), true)); }
public virtual HashSet <Occurrence> GetOccurrences(IDateTime dt) { return(RecurrenceUtil.GetOccurrences(this, dt, true)); }