I have a list of work items. Each work item has a start and an end time.
So basically it looks like this:
List<Work> works = new List<Work>();
works.Add(new Work(
new DateTime(2013, 4, 30, 9, 0, 0),
new DateTime(2013, 4, 30, 11, 0, 0));
Now I want to get the total time. Again, basically this is easy:
09:00-11:00 => 2 hours
13:00-17:00 => 4 hours
----
06:00 hours
This is just the sum.
But now itβs becoming difficult: how do I calculate this amount if I want to extract parallel time?
eg.
09:00-11:00 => 2 hours
10:00-11:30 => 1.5 hours
13:00-17:00 => 4 hours
----
06:30 hours
is 6.5 hours, but the amount is 7.5 hours. The fact that two work items correspond to a time between 10 and 11 hours makes a difference.
How can I solve this for an arbitrary number of work items that can overlap with each other basically in all possible ways (ambient, static overlaps, overlapping ends, including)?
source
share