/// <summary>The <see cref="ITimeInterval"/> that <see cref="Contains(ITimeInterval,ITimePoint)"/> all the <see cref="ITimePoint"/>s that both <paramref name="other"/> and <paramref name="me"/> <see cref="Contains(ITimeInterval,ITimePoint)"/>.</summary>
 public static ITimeInterval IntersectionWith(this ITimeInterval me, ITimeInterval other)
 {
     var start = TimePoint.Latest(me.FirstInstant(), other.FirstInstant());
     var end = TimePoint.Earliest(me.LastInstant(), other.LastInstant());
     if(start.IsAfterOrSameInstantAs(end)) //Detect non-intersecting case.
     {
         return NewTimeInterval(start, Duration.Zero);
     }
     return NewTimeInterval(start, Duration.Between(start, end));
 }
Ejemplo n.º 2
0
        /// <summary>The <see cref="ITimeInterval"/> that <see cref="Contains(ITimeInterval,ITimePoint)"/> all the <see cref="ITimePoint"/>s that both <paramref name="other"/> and <paramref name="me"/> <see cref="Contains(ITimeInterval,ITimePoint)"/>.</summary>
        public static ITimeInterval IntersectionWith(this ITimeInterval me, ITimeInterval other)
        {
            var start = TimePoint.Latest(me.FirstInstant(), other.FirstInstant());
            var end   = TimePoint.Earliest(me.LastInstant(), other.LastInstant());

            if (start.IsAfterOrSameInstantAs(end)) //Detect non-intersecting case.
            {
                return(NewTimeInterval(start, Duration.Zero));
            }
            return(NewTimeInterval(start, Duration.Between(start, end)));
        }
 /// <summary>True if <paramref name="me"/> contains every <see cref="ITimePoint"/> that <paramref name="other"/> contains</summary>
 public static bool Contains(this ITimeInterval me, ITimeInterval other)
 {
     return me.Contains(other.FirstInstant()) && me.Contains(other.LastInstant());
 }
Ejemplo n.º 4
0
 /// <summary>True if <paramref name="me"/> contains every <see cref="ITimePoint"/> that <paramref name="other"/> contains</summary>
 public static bool Contains(this ITimeInterval me, ITimeInterval other)
 {
     return(me.Contains(other.FirstInstant()) && me.Contains(other.LastInstant()));
 }
Ejemplo n.º 5
0
 /// <summary>The last <see cref="ITimePoint"/> before <paramref name="me"/> that is not part of the interval.<paramref name="me"/></summary>
 public static ITimePoint LastInstantBefore(this ITimeInterval me)
 {
     return(me.FirstInstant().PreviousInstant());
 }