예제 #1
0
        /// <summary>
        ///     Gets the intersection of the two <see cref="TimeRange"/> instances.
        /// </summary>
        /// <param name="x">
        ///     The first time range.
        /// </param>
        /// <param name="y">
        ///     The second time range.
        /// </param>
        /// <returns>
        ///     The intersection, if one exists; <c>null</c> otherwise.
        /// </returns>
        public static TimeRange?Intersect(TimeRange x, TimeRange y)
        {
            Timestamp maxStartTime = Timestamp.Max(x.AsOrdered().StartTime, y.AsOrdered().StartTime);
            Timestamp minEndTime   = Timestamp.Min(x.AsOrdered().EndTime, y.AsOrdered().EndTime);

            if (minEndTime < maxStartTime)
            {
                return(null);
            }

            return(new TimeRange(maxStartTime, minEndTime));
        }
 /// <summary>
 ///     Gets the minimum time in the <see cref="TimeRange"/>.
 /// </summary>
 /// <param name="timeRange">
 ///     The time range.
 /// </param>
 /// <returns>
 ///     The minimum value.
 /// </returns>
 public static Timestamp MinTime(this TimeRange timeRange)
 {
     return(Timestamp.Min(timeRange.StartTime, timeRange.EndTime));
 }