For discrete time indices (represented as integers, i.e. years, quarters,
months, weeks, dates, arbitrary integer indices) time intervals represent
the following sets (ignoring empty, i.e. with \(a_i > b_i\)):
$$\bigcup_{i = 1}^n A_i = \bigcup_{i = 1}^n \{x: a_i \le x \le b_i\} = \bigcup_{i = 1}^n \{a_i, a_i + 1, \dots, b_i - 1, b_i\}.$$
unique returns the unique (canonical) representation of the set above:
$$\bigcup_{i = 1}^{n'} A'_i = \bigcup_{i = 1}^{n'} \{a'_i, a'_i + 1, \dots, b'_i - 1, b'_i\}$$
with \(a'_i \le b'_i < a'_{i + 1} - 1\), i.e. as a sum of ordered, non-empty,
non-adjacent intervals.
For continuous time indices (representing point in time, i.e. date-time, time of day,
arbitrary numeric indices) time intervals represent the following sets
(ignoring empty, i.e. with \(a_i \ge b_i\)):
$$\bigcup_{i = 1}^n A_i = \bigcup_{i = 1}^n [a_i, b_i).$$
unique returns unique representation of the set above:
$$\bigcup_{i = 1}^{n'} A'_i = \bigcup_{i = 1}^{n'} [a'_i, b'_i)$$
with \(a'_i < b'_i < a'_{i + 1}\), i.e. as a sum of ordered, non-empty,
non-adjacent intervals.
Complement of a single interval for integer indices
$$\{x: a \le x \le b\} = \{a, a + 1, \dots, b - 1, b\}$$
is:
$$\{x: x < a\} \cup \{x: x > b\} = \{x: x \le a - 1\} \cup \{x: x \ge b + 1\} = \{\dots, a - 2, a - 1\} \cup \{b + 1, b + 2, \dots\}.$$
Complement of a single interval for continuous indices
$$[a, b)$$
is:
$$(-\infty, a) \cup [b, \infty).$$
Complement of a sum of intervals is the intersection of complements.
Set operations always return results in the canonical representation.