public void AssociateWith(IDateTime dt)
{
if (AssociatedObject == null && dt.AssociatedObject != null)
AssociatedObject = dt.AssociatedObject;
else if (AssociatedObject != null && dt.AssociatedObject == null)
dt.AssociatedObject = AssociatedObject;
// If these share the same TZID, then let's see if we
// can share the time zone observance also!
if (TZID != null && string.Equals(TZID, dt.TZID))
{
if (TimeZoneObservance != null && dt.TimeZoneObservance == null)
{
IDateTime normalizedDt = new iCalDateTime(TimeZoneObservance.Value.TimeZoneInfo.OffsetTo.ToUTC(dt.Value));
if (TimeZoneObservance.Value.Contains(normalizedDt))
dt.TimeZoneObservance = TimeZoneObservance;
}
else if (dt.TimeZoneObservance != null && TimeZoneObservance == null)
{
IDateTime normalizedDt = new iCalDateTime(dt.TimeZoneObservance.Value.TimeZoneInfo.OffsetTo.ToUTC(Value));
if (dt.TimeZoneObservance.Value.Contains(normalizedDt))
TimeZoneObservance = dt.TimeZoneObservance;
}
}
}
public override IList <IPeriod> Evaluate(IDateTime referenceDate, DateTime periodStart, DateTime periodEnd, bool includeReferenceDateInResults) { // Create a recurrence pattern suitable for use during evaluation. IRecurrencePattern pattern = ProcessRecurrencePattern(referenceDate); // Enforce evaluation restrictions on the pattern. EnforceEvaluationRestrictions(pattern); Periods.Clear(); foreach (DateTime dt in GetDates(referenceDate, periodStart, periodEnd, -1, pattern, includeReferenceDateInResults)) { // Turn each resulting date/time into an IDateTime and associate it // with the reference date. IDateTime newDt = new iCalDateTime(dt, referenceDate.TZID); // NOTE: fixes bug #2938007 - hasTime missing newDt.HasTime = referenceDate.HasTime; newDt.AssociateWith(referenceDate); // Create a period from the new date/time. IPeriod p = new Period(newDt); if (!Periods.Contains(p)) { Periods.Add(p); } } return(Periods); }