In the general case, [A, B)
(inclusive start, exclusive end) has a lot going for it and I don’t see any reason why the same wouldn’t be true for time intervals.
Djikstra wrote a nice article about it Why numbering should start at zero which – despite the name – deals mostly with exactly this.
Short summary of the advantages:
end - start
equals the number of items in the list- upper bound of preceding interval is the lower bound of the next
- allows to index an interval starting from 0 with unsigned numbers [1]
Personally the second point is extremely useful for lots of problems; consider a pretty standard recursive function (in pseudo python):
def foo(start, end):
if end - start == 1:
# base case
else:
middle = start + (end - start) / 2
foo(start, middle)
foo(middle, end)
Writing the same with inclusive upper bound introduces lots of error prone off by one errors.
[1] That’s the advantage compared to (A, B]
– a interval starting from 0 is MUCH more common than an interval ending in MAX_VAL
. Note that also relates to one additional problem: Using two inclusive bounds means we can denote a sequence whose length cannot be expressed with the same size.