public static double GetIntervalIntersection(DateTimeInterval interval1, DateTimeInterval interval2) { if (interval1.From == null || interval1.To == null || interval2.From == null || interval2.To == null) { throw new ArgumentException("DateTimeUtils.GetIntervalIntersection - argument can not be null"); } DateTime from = interval1.From.Value < interval2.From.Value ? interval2.From.Value : interval1.From.Value; DateTime to = interval1.To.Value > interval2.To.Value ? interval2.To.Value : interval1.To.Value; return((to - from).TotalMinutes); }
private static DateTimeInterval Combine(DateTimeInterval start, DateTimeInterval end) { return(new DateTimeInterval(start.From, Max(start.To, end.To))); }