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

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

        return(intersects
            ? new DateOnlyInterval(start, end)
            : (DateOnlyInterval?)null);
    }
コード例 #3
0
    public bool Contains(DateOnlyInterval other)
    {
        var contains = Start <= other.Start && other.End <= End;

        return(contains);
    }
コード例 #4
0
 public static bool Starts(this DateOnlyInterval x, DateOnlyInterval y) => x.Start == y.Start && x.End < y.End;
コード例 #5
0
 public static bool OverlapsWith(this DateOnlyInterval x, DateOnlyInterval y) => x.Start < y.Start && y.Start <= x.End && x.End < y.End;
コード例 #6
0
 public static bool Meets(this DateOnlyInterval x, DateOnlyInterval y) => x.End.Next == y.Start;
コード例 #7
0
 public static bool Precedes(this DateOnlyInterval x, DateOnlyInterval y) => x.End.Next < y.Start;
コード例 #8
0
    public static TemporalIntervalRelation GetTemporalIntervalRelation(this DateOnlyInterval x, DateOnlyInterval y)
    {
        TemporalIntervalRelation relation;

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

        return(relation);
    }
コード例 #9
0
 public static bool Finishes(this DateOnlyInterval x, DateOnlyInterval y) => y.Start < x.Start && x.End == y.End;
コード例 #10
0
 public static bool IsFinishedBy(this DateOnlyInterval x, DateOnlyInterval y) => Finishes(y, x);
コード例 #11
0
 public static bool Contains(this DateOnlyInterval x, DateOnlyInterval y) => During(y, x);
コード例 #12
0
 public static bool IsStartedBy(this DateOnlyInterval x, DateOnlyInterval y) => Starts(y, x);
コード例 #13
0
 public static bool IsOverlappedBy(this DateOnlyInterval x, DateOnlyInterval y) => OverlapsWith(y, x);
コード例 #14
0
 public static bool IsMetBy(this DateOnlyInterval x, DateOnlyInterval y) => Meets(y, x);
コード例 #15
0
 public static bool IsPrecededBy(this DateOnlyInterval x, DateOnlyInterval y) => Precedes(y, x);
コード例 #16
0
 public static bool IsEqualTo(this DateOnlyInterval x, DateOnlyInterval y) => x.Start == y.Start && x.End == y.End;
コード例 #17
0
 public static bool During(this DateOnlyInterval x, DateOnlyInterval y) => y.Start < x.Start && x.End < y.End;