ISO8601 icon indicating copy to clipboard operation
ISO8601 copied to clipboard

Add time interval `#union`

Open arnau opened this issue 8 years ago • 3 comments

Add TimeInterval#union to merge two intervals. And consider if they need to intersect or not. If not, the behaviour could be unexpected (?)

arnau avatar Dec 13 '15 12:12 arnau

Some more thoughts on treating a TimeInterval like an ordered set:

Let's define the empty interval properties first:

  • An empty interval has length 0.
  • If A and B are empty intervals, A == B.
  • start_time == end_time if true for an empty interval.

Questions:

  • What are the values of start_time and end_time?
  • What is the ISO8601 representation of an empty interval, PT0S (notice the lack of time point)?

arnau avatar Dec 13 '15 19:12 arnau

If we define an empty set as:

  • An empty interval has length 0, start_time == end_time == 0.
  • A(st_a, et_a) != B(st_b, et_b) if (st_a, et_a) != (st_b, et_b)

Then the result of an empty intersection is not possible to represent, unless we do something like creating an empty interval based on the start_time of the initial interval, so an arbitrary decision.

arnau avatar Dec 13 '15 19:12 arnau

Maybe the solution is to go away from known concepts and try to use something like #blend instead of #union. So a A(st_a, et_a) blend B(st_b, et_b) operation where st_a < st_b and et_a < et_b would result on C(st_c, et_c) where st_c = st_a and et_c = st_b.

So the resulting interval would contain new time points if A and B have no intersection.

arnau avatar Dec 14 '15 11:12 arnau