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); }
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); }
public static bool Precedes(this SmallDateInterval x, SmallDateInterval y) => x.End.Next < y.Start;
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); }
public static bool IsEqualTo(this SmallDateInterval x, SmallDateInterval y) => x.Start == y.Start && x.End == y.End;
public static bool IsFinishedBy(this SmallDateInterval x, SmallDateInterval y) => y.Finishes(x);
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); }
public static bool Starts(this SmallDateInterval x, SmallDateInterval y) => x.Start == y.Start && x.End < y.End;
public static bool IsMetBy(this SmallDateInterval x, SmallDateInterval y) => y.Meets(x);
public static bool IsPrecededBy(this SmallDateInterval x, SmallDateInterval y) => y.Precedes(x);
public static bool Finishes(this SmallDateInterval x, SmallDateInterval y) => y.Start < x.Start && x.End == y.End;
public static bool During(this SmallDateInterval x, SmallDateInterval y) => y.Start < x.Start && x.End < y.End;
public static bool Meets(this SmallDateInterval x, SmallDateInterval y) => x.End.AddDays(1) == y.Start;
public static bool Before(this SmallDateInterval x, SmallDateInterval y) => x.End < y.Start;
public static bool Meets(this SmallDateInterval x, SmallDateInterval y) => x.End.Next == y.Start;
public static bool OverlapsWith(this SmallDateInterval x, SmallDateInterval y) => x.Start < y.Start && y.Start <= x.End && x.End < y.End;
public static bool IsOverlappedBy(this SmallDateInterval x, SmallDateInterval y) => y.OverlapsWith(x);
public bool Contains(SmallDateInterval other) { var contains = Start.Value <= other.Start.Value && other.End.Value <= End.Value; return(contains); }
public static bool IsStartedBy(this SmallDateInterval x, SmallDateInterval y) => y.Starts(x);
public static bool Contains(this SmallDateInterval x, SmallDateInterval y) => y.During(x);
public static bool After(this SmallDateInterval x, SmallDateInterval y) => y.Before(x);