/// <summary> /// Returns all occurrences of this component that start within the date range provided. /// All components occurring between <paramref name="startTime" /> and <paramref name="endTime" /> /// will be returned. /// </summary> /// <param name="startTime">The starting date range</param> /// <param name="endTime">The ending date range</param> /// <returns></returns> public IList <Occurrence> GetOccurrences(IDateTime startTime, IDateTime endTime) { return(RecurrenceUtil.GetOccurrences(this, startTime, endTime, true)); }
/// <summary> /// Gets the occurrences. /// </summary> /// <param name="startTime">The start time.</param> /// <param name="endTime">The end time.</param> /// <returns></returns> public IList <Occurrence> GetOccurrences(DateTime startTime, DateTime endTime) { return(RecurrenceUtil.GetOccurrences(this, new iCalDateTime(startTime), new iCalDateTime(endTime), true)); }
/// <summary> /// Returns all occurrences of this component that start on the date provided. /// All components starting between 12:00:00AM and 11:59:59 PM will be /// returned. /// <note> /// This will first Evaluate() the date range required in order to /// determine the occurrences for the date provided, and then return /// the occurrences. /// </note> /// </summary> /// <param name="dt">The date for which to return occurrences.</param> /// <returns> /// A list of Periods representing the occurrences of this object. /// </returns> public IList <Occurrence> GetOccurrences(IDateTime dt) { return(RecurrenceUtil.GetOccurrences(this, dt, true)); }
/// <summary> /// Gets the occurrences. /// </summary> /// <param name="dt">The date time.</param> /// <returns></returns> public IList <Occurrence> GetOccurrences(DateTime dt) { return(RecurrenceUtil.GetOccurrences(this, new iCalDateTime(dt), true)); }
/// <summary> /// Clears a previous evaluation, usually because one of the /// key elements used for evaluation has changed /// (Start, End, Duration, recurrence rules, exceptions, etc.). /// </summary> public void ClearEvaluation( ) { RecurrenceUtil.ClearEvaluation(this); }
/// <summary> /// Gets the occurrences. /// </summary> /// <param name="startTime">The start time.</param> /// <param name="endTime">The end time.</param> /// <returns></returns> public virtual IList <Occurrence> GetOccurrences(DateTime startTime, DateTime endTime) { return(RecurrenceUtil.GetOccurrences(this, new iCalDateTime(startTime), new iCalDateTime(endTime), EvaluationIncludesReferenceDate)); }
/// <summary> /// Returns all occurrences of this component that start within the date range provided. /// All components occurring between <paramref name="startTime" /> and <paramref name="endTime" /> /// will be returned. /// </summary> /// <param name="startTime">The starting date range</param> /// <param name="endTime">The ending date range</param> /// <returns></returns> public virtual IList <Occurrence> GetOccurrences(IDateTime startTime, IDateTime endTime) { return(RecurrenceUtil.GetOccurrences(this, startTime, endTime, EvaluationIncludesReferenceDate)); }
/// <summary> /// Gets the occurrences. /// </summary> /// <param name="dt">The date time.</param> /// <returns></returns> public virtual IList <Occurrence> GetOccurrences(DateTime dt) { return(RecurrenceUtil.GetOccurrences(this, new iCalDateTime(dt), EvaluationIncludesReferenceDate)); }
/// <summary> /// Gets the dates. /// </summary> /// <param name="seed">The seed.</param> /// <param name="periodStart">The period start.</param> /// <param name="periodEnd">The period end.</param> /// <param name="maxCount">The max count.</param> /// <param name="pattern">The pattern.</param> /// <param name="includeReferenceDateInResults"> /// if set to <c>true</c> [include reference date in results]. /// </param> /// <returns></returns> private IEnumerable <DateTime> GetDates(IDateTime seed, DateTime periodStart, DateTime periodEnd, int maxCount, IRecurrencePattern pattern, bool includeReferenceDateInResults) { var dates = new List <DateTime>( ); DateTime originalDate = DateUtil.GetSimpleDateTimeData(seed); DateTime seedCopy = DateUtil.GetSimpleDateTimeData(seed); if (includeReferenceDateInResults) { dates.Add(seedCopy); } // If the interval is set to zero, or our count prevents us // from getting additional items, then return with the reference // date only. if (pattern.Interval == 0 || (pattern.Count != int.MinValue && pattern.Count <= dates.Count)) { return(dates); } // optimize the start time for selecting candidates // (only applicable where a COUNT is not specified) if (pattern.Count == int.MinValue) { DateTime incremented = seedCopy; // FIXME: we can more aggressively increment here when // the difference between dates is greater. IncrementDate(ref incremented, pattern, pattern.Interval); while (incremented < periodStart) { seedCopy = incremented; IncrementDate(ref incremented, pattern, pattern.Interval); } } bool?[] expandBehavior = RecurrenceUtil.GetExpandBehaviorList(pattern); int invalidCandidateCount = 0; int noCandidateIncrementCount = 0; DateTime candidate = DateTime.MinValue; while ((maxCount < 0) || (dates.Count < maxCount)) { if (pattern.Until != DateTime.MinValue && candidate != DateTime.MinValue && candidate > pattern.Until) { break; } if (candidate != DateTime.MinValue && candidate > periodEnd) { break; } if (pattern.Count >= 1 && (dates.Count + invalidCandidateCount) >= pattern.Count) { break; } List <DateTime> candidates = GetCandidates(seedCopy, pattern, expandBehavior); if (candidates.Count > 0) { noCandidateIncrementCount = 0; // sort candidates for identifying when UNTIL date is exceeded.. candidates.Sort( ); foreach (DateTime t in candidates) { candidate = t; // don't count candidates that occur before the original date.. if (candidate >= originalDate) { // candidates MAY occur before periodStart // For example, FREQ=YEARLY;BYWEEKNO=1 could return dates // from the previous year. // // candidates exclusive of periodEnd.. if (candidate >= periodEnd) { invalidCandidateCount++; } else if (pattern.Count >= 1 && (dates.Count + invalidCandidateCount) >= pattern.Count) { break; } else if (pattern.Until == DateTime.MinValue || candidate <= pattern.Until) { if (!dates.Contains(candidate)) { dates.Add(candidate); } } } } } else { noCandidateIncrementCount++; if ((noCandidateIncrementCount > MaxIncrementCount)) { break; } } IncrementDate(ref seedCopy, pattern, pattern.Interval); } // sort final list.. dates.Sort( ); return(dates); }