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);
    }
    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);
    }
    public bool Contains(DateOnlyInterval other)
    {
        var contains = Start <= other.Start && other.End <= End;

        return(contains);
    }
Exemple #4
0
 public static bool Starts(this DateOnlyInterval x, DateOnlyInterval y) => x.Start == y.Start && x.End < y.End;
Exemple #5
0
 public static bool OverlapsWith(this DateOnlyInterval x, DateOnlyInterval y) => x.Start < y.Start && y.Start <= x.End && x.End < y.End;
Exemple #6
0
 public static bool Meets(this DateOnlyInterval x, DateOnlyInterval y) => x.End.Next == y.Start;
Exemple #7
0
 public static bool Precedes(this DateOnlyInterval x, DateOnlyInterval y) => x.End.Next < y.Start;
Exemple #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);
    }
Exemple #9
0
 public static bool Finishes(this DateOnlyInterval x, DateOnlyInterval y) => y.Start < x.Start && x.End == y.End;
Exemple #10
0
 public static bool IsFinishedBy(this DateOnlyInterval x, DateOnlyInterval y) => Finishes(y, x);
Exemple #11
0
 public static bool Contains(this DateOnlyInterval x, DateOnlyInterval y) => During(y, x);
Exemple #12
0
 public static bool IsStartedBy(this DateOnlyInterval x, DateOnlyInterval y) => Starts(y, x);
Exemple #13
0
 public static bool IsOverlappedBy(this DateOnlyInterval x, DateOnlyInterval y) => OverlapsWith(y, x);
Exemple #14
0
 public static bool IsMetBy(this DateOnlyInterval x, DateOnlyInterval y) => Meets(y, x);
Exemple #15
0
 public static bool IsPrecededBy(this DateOnlyInterval x, DateOnlyInterval y) => Precedes(y, x);
Exemple #16
0
 public static bool IsEqualTo(this DateOnlyInterval x, DateOnlyInterval y) => x.Start == y.Start && x.End == y.End;
Exemple #17
0
 public static bool During(this DateOnlyInterval x, DateOnlyInterval y) => y.Start < x.Start && x.End < y.End;