Skip to content

Commit

Permalink
Fix intersection of open periods
Browse files Browse the repository at this point in the history
  • Loading branch information
hazzik committed Jun 26, 2024
1 parent 2d307e3 commit b9cf290
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion projects/GKCore/GDModel/GDMCustomDate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ public static GDMDatePeriod GetIntersection(GDMCustomDate range1, GDMCustomDate
GDMDate smallestEnd = r1end.IsEmpty() ? r2end : (r2end.IsEmpty() ? r1end : (r1end.CompareTo(r2end) < 0) ? r1end : r2end);

// no intersection
if (greatestStart.CompareTo(smallestEnd) > 0) {
if (greatestStart.CompareTo(smallestEnd) > 0 && !greatestStart.IsEmpty() && !smallestEnd.IsEmpty()) {
return GDMDatePeriod.Empty;
}

Expand Down
2 changes: 2 additions & 0 deletions projects/GKTests/GDModel/GDMLocationRecordTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,8 @@ public void Test_DateIntersections()

Assert.AreEqual("FROM 1782 TO 1834", GDMCustomDate.GetIntersection(GetRange("FROM 1782"), GetRange("TO 1834")).StringValue);
Assert.AreEqual("FROM 1782 TO 1834", GDMCustomDate.GetIntersection(GetRange("TO 1834"), GetRange("FROM 1782")).StringValue);
Assert.AreEqual("FROM 1782", GDMCustomDate.GetIntersection(GetRange("FROM 1782"), GetRange("FROM 1782")).StringValue);
Assert.AreEqual("FROM 1834", GDMCustomDate.GetIntersection(GetRange("FROM 1782"), GetRange("FROM 1834")).StringValue);

Assert.AreEqual("", GDMCustomDate.GetIntersection(GetRange("FROM 1858"), GetRange("TO 1834")).StringValue); // no intersects
Assert.AreEqual("", GDMCustomDate.GetIntersection(GetRange("TO 1834"), GetRange("FROM 1858")).StringValue); // no intersects
Expand Down

0 comments on commit b9cf290

Please sign in to comment.