public static IDateTime MatchTimeZone(IDateTime dt1, IDateTime dt2) { Debug.Assert(dt1 != null && dt2 != null); // Associate the date/time with the first. IDateTime copy = dt2.Copy <IDateTime>(); copy.AssociateWith(dt1); // If the dt1 time does not occur in the same time zone as the // dt2 time, then let's convert it so they can be used in the // same context (i.e. evaluation). if (dt1.TZID != null) { if (!string.Equals(dt1.TZID, copy.TZID)) { return((dt1.TimeZoneObservance != null) ? copy.ToTimeZone(dt1.TimeZoneObservance.Value) : copy.ToTimeZone(dt1.TZID)); } else { return(copy); } } else if (dt1.IsUniversalTime) { // The first date/time is in UTC time, convert! return(new iCalDateTime(copy.UTC)); } else { // The first date/time is in local time, convert! return(new iCalDateTime(copy.Local)); } }