KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have four DateTime objects. A1, A2 and B1, B2. I need to know that the period A1-A2 doesn't intersect with period B1-B2. But I don`t want to write dirty code, like many if blocks. if (A1 < B1 && A2 > B1) { return false; } .... etc. EDITED I tried to use this one: Comparing ranges DateTime A1 = DateTime.MinValue.AddMinutes(61); DateTime A2 = DateTime.MinValue.AddHours(1.2); DateTime B1 = DateTime.MinValue.AddMinutes(5); DateTime B2 = DateTime.MinValue.AddHours(1); Console.WriteLine(Range.Overlap( new Range<DateTime>(A1, A2), new Range<DateTime>(B1, B2) )); It returned true but I expected false . Because this code always returns true if (left.Start.CompareTo(left.Start) == 0) { return true; }
Tags (comma-separated)
Save Edits
Cancel