From b9cf290b2c81c2a9f13229651b1989f0fe9d8b0f Mon Sep 17 00:00:00 2001 From: Alex Zaytsev Date: Wed, 26 Jun 2024 20:48:06 +1000 Subject: [PATCH] Fix intersection of open periods --- projects/GKCore/GDModel/GDMCustomDate.cs | 2 +- projects/GKTests/GDModel/GDMLocationRecordTests.cs | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/projects/GKCore/GDModel/GDMCustomDate.cs b/projects/GKCore/GDModel/GDMCustomDate.cs index 088cf6919..af7cb70b2 100644 --- a/projects/GKCore/GDModel/GDMCustomDate.cs +++ b/projects/GKCore/GDModel/GDMCustomDate.cs @@ -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; } diff --git a/projects/GKTests/GDModel/GDMLocationRecordTests.cs b/projects/GKTests/GDModel/GDMLocationRecordTests.cs index 2b1d63af8..f4836a96a 100644 --- a/projects/GKTests/GDModel/GDMLocationRecordTests.cs +++ b/projects/GKTests/GDModel/GDMLocationRecordTests.cs @@ -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