コード例 #1
0
        public bool Intersects(SmallDateInterval other)
        {
            var start      = ElementPair.Max(Start, other.Start);
            var end        = ElementPair.Min(End, other.End);
            var intersects = start <= end;

            return(intersects);
        }
コード例 #2
0
        public SmallDateInterval?Intersect(SmallDateInterval other)
        {
            var start      = ElementPair.Max(Start, other.Start);
            var end        = ElementPair.Min(End, other.End);
            var intersects = start <= end;

            return(intersects
                ? new SmallDateInterval(start, end)
                : (SmallDateInterval?)null);
        }
コード例 #3
0
 public static bool Precedes(this SmallDateInterval x, SmallDateInterval y) => x.End.Next < y.Start;
コード例 #4
0
        public static TemporalIntervalRelation GetTemporalIntervalRelation(this SmallDateInterval x, SmallDateInterval y)
        {
            TemporalIntervalRelation relation;

            if (x.Precedes(y))
            {
                relation = TemporalIntervalRelation.Precedes;
            }
            else if (x.Meets(y))
            {
                relation = TemporalIntervalRelation.Meets;
            }
            else if (x.OverlapsWith(y))
            {
                relation = TemporalIntervalRelation.OverlapsWith;
            }
            else if (x.Starts(y))
            {
                relation = TemporalIntervalRelation.Starts;
            }
            else if (x.During(y))
            {
                relation = TemporalIntervalRelation.During;
            }
            else if (x.Finishes(y))
            {
                relation = TemporalIntervalRelation.Finishes;
            }
            else if (x.IsPrecededBy(y))
            {
                relation = TemporalIntervalRelation.IsPrecededBy;
            }
            else if (x.IsMetBy(y))
            {
                relation = TemporalIntervalRelation.IsMetBy;
            }
            else if (x.IsOverlappedBy(y))
            {
                relation = TemporalIntervalRelation.IsOverlappedBy;
            }
            else if (x.IsStartedBy(y))
            {
                relation = TemporalIntervalRelation.IsStartedBy;
            }
            else if (Contains(x, y))
            {
                relation = TemporalIntervalRelation.Contains;
            }
            else if (x.IsFinishedBy(y))
            {
                relation = TemporalIntervalRelation.IsFinishedBy;
            }
            else if (x.IsEqualTo(y))
            {
                relation = TemporalIntervalRelation.IsEqualTo;
            }
            else
            {
                throw new InvalidOperationException();
            }

            return(relation);
        }
コード例 #5
0
 public static bool IsEqualTo(this SmallDateInterval x, SmallDateInterval y) => x.Start == y.Start && x.End == y.End;
コード例 #6
0
 public static bool IsFinishedBy(this SmallDateInterval x, SmallDateInterval y) => y.Finishes(x);
コード例 #7
0
        public static TemporalIntervalRelation GetTemporalIntervalRelation(this SmallDateInterval x, SmallDateInterval y)
        {
            TemporalIntervalRelation relation;

            if (x.Before(y))
            {
                relation = TemporalIntervalRelation.Before;
            }
            else if (x.Meets(y))
            {
                relation = TemporalIntervalRelation.Meets;
            }
            else if (x.Overlaps(y))
            {
                relation = TemporalIntervalRelation.Overlaps;
            }
            else if (x.Starts(y))
            {
                relation = TemporalIntervalRelation.Starts;
            }
            else if (x.During(y))
            {
                relation = TemporalIntervalRelation.During;
            }
            else if (x.Finishes(y))
            {
                relation = TemporalIntervalRelation.Finishes;
            }
            else if (x.Equal(y))
            {
                relation = TemporalIntervalRelation.Equal;
            }
            else if (x.After(y))
            {
                relation = TemporalIntervalRelation.After;
            }
            else if (x.MetBy(y))
            {
                relation = TemporalIntervalRelation.MetBy;
            }
            else if (x.OverlappedBy(y))
            {
                relation = TemporalIntervalRelation.OverlappedBy;
            }
            else if (x.StartedBy(y))
            {
                relation = TemporalIntervalRelation.StartedBy;
            }
            else if (x.Contains(y))
            {
                relation = TemporalIntervalRelation.Contains;
            }
            else if (x.FinishedBy(y))
            {
                relation = TemporalIntervalRelation.FinishedBy;
            }
            else
            {
                throw new InvalidOperationException();
            }

            return(relation);
        }
コード例 #8
0
 public static bool Starts(this SmallDateInterval x, SmallDateInterval y) => x.Start == y.Start && x.End < y.End;
コード例 #9
0
 public static bool IsMetBy(this SmallDateInterval x, SmallDateInterval y) => y.Meets(x);
コード例 #10
0
 public static bool IsPrecededBy(this SmallDateInterval x, SmallDateInterval y) => y.Precedes(x);
コード例 #11
0
 public static bool Finishes(this SmallDateInterval x, SmallDateInterval y) => y.Start < x.Start && x.End == y.End;
コード例 #12
0
 public static bool During(this SmallDateInterval x, SmallDateInterval y) => y.Start < x.Start && x.End < y.End;
コード例 #13
0
 public static bool Meets(this SmallDateInterval x, SmallDateInterval y) => x.End.AddDays(1) == y.Start;
コード例 #14
0
 public static bool Before(this SmallDateInterval x, SmallDateInterval y) => x.End < y.Start;
コード例 #15
0
 public static bool Meets(this SmallDateInterval x, SmallDateInterval y) => x.End.Next == y.Start;
コード例 #16
0
 public static bool OverlapsWith(this SmallDateInterval x, SmallDateInterval y) => x.Start < y.Start && y.Start <= x.End && x.End < y.End;
コード例 #17
0
 public static bool IsOverlappedBy(this SmallDateInterval x, SmallDateInterval y) => y.OverlapsWith(x);
コード例 #18
0
        public bool Contains(SmallDateInterval other)
        {
            var contains = Start.Value <= other.Start.Value && other.End.Value <= End.Value;

            return(contains);
        }
コード例 #19
0
 public static bool IsStartedBy(this SmallDateInterval x, SmallDateInterval y) => y.Starts(x);
コード例 #20
0
 public static bool Contains(this SmallDateInterval x, SmallDateInterval y) => y.During(x);
コード例 #21
0
 public static bool After(this SmallDateInterval x, SmallDateInterval y) => y.Before(x);