[[Property:title|Interval]]
[[Property:weight|2]]
[[Property:uuid|d33d0216-fa71-60dc-f3b0-61ff42d621e6]]
Class <eiffel>INTERVAL [G -> ABSOLUTE]</eiffel> deals with intervals between two instances of the same class (an actual generic parameter substituting for <eiffel>G</eiffel>) which conforms to<eiffel> ABSOLUTE</eiffel> (specifically: <eiffel>DATE</eiffel>, <eiffel>TIME</eiffel>, <eiffel>DATE_TIME</eiffel>). 
====Creation====

The creation procedure 
<eiffel>
    make (s, e: G)</eiffel>
takes as arguments two instances of type <eiffel>G</eiffel> (or <eiffel>G</eiffel>'s actual type from a declaration, e.g., <eiffel>my_time_interval: INTERVAL [TIME]</eiffel> ), which will become the start bound and the end bound of the <eiffel>INTERVAL</eiffel>. The start bound argument must be "before" the end bound argument (i.e., <eiffel>s <= e</eiffel>). <eiffel>make</eiffel> creates twins of its arguments so that the objects referenced as arguments will not change even if the values in the <eiffel>INTERVAL</eiffel> change.

====Interval measurement====

The measurement of an interval is done by applying the query <eiffel>duration</eiffel>. Although the result of <eiffel>duration</eiffel> will be an instance of class <eiffel>DURATION</eiffel>, it will be a direct instance of the <eiffel>DURATION</eiffel> descendant that is appropriate to the actual value of the generic parameter <eiffel>G</eiffel>. So, for an <eiffel>INTERVAL [TIME]</eiffel>, the result of <eiffel>duration</eiffel> will be a direct instance of <eiffel>TIME_DURATION</eiffel>.

====Comparison====

* <eiffel>infix <</eiffel> and <eiffel>infix ></eiffel> compare two intervals on a "strict" basis. This means that <eiffel>int_1 < int_2</eiffel> is <eiffel>True</eiffel> if <eiffel>int_1</eiffel> starts and ends strictly before <eiffel>int_2</eiffel>. In other words, <eiffel>int_1</eiffel> must have a start bound less than that of <eiffel>int_2</eiffel> and an end bound less than that of <eiffel>int_2</eiffel>.
* <eiffel>infix <=</eiffel> and <eiffel>infix >=</eiffel> compare two intervals on a non-strict basis. So, <eiffel>int_1 <= int_2</eiffel> is <eiffel>True</eiffel> if <eiffel>int_1</eiffel> has a start bound less than or equal to that of <eiffel>int_2</eiffel> and an end bound less than or equal to that of <eiffel>int_2</eiffel>.
* <eiffel>is_equal</eiffel> (or <eiffel>~</eiffel>)performs object comparison.
* <eiffel>intersects</eiffel> is true if one (target) <eiffel>INTERVAL</eiffel> shares some of the same bounded area with a second (argument) <eiffel>INTERVAL</eiffel>.
* <eiffel>overlaps</eiffel> is similar to <eiffel>intersects</eiffel> with the exception that the argument <eiffel>INTERVAL</eiffel> has to be after the target <eiffel>INTERVAL</eiffel>. <eiffel>is_overlapped</eiffel> is the opposite of <eiffel>overlaps</eiffel>.
* <eiffel>meets</eiffel> and <eiffel>is_met</eiffel> are used to test whether two intervals have a common bound.
* <eiffel>strict_includes</eiffel> can be used to test whether the target <eiffel>INTERVAL</eiffel> strictly includes the argument <eiffel>INTERVAL</eiffel>. So, <eiffel> int_1.strict_includes (int_2) </eiffel> will be <eiffel>True</eiffel> if the start bound of <eiffel>int_2</eiffel> is greater than the start bound of <eiffel>int_1</eiffel> and the end bound of <eiffel>int_2</eiffel> is less than the end bound of <eiffel>int_1</eiffel>. <eiffel>is_strict_included_by</eiffel> provides the opposite of <eiffel>strict_includes</eiffel>.
* <eiffel>includes</eiffel> and <eiffel>is_included_by</eiffel> test for inclusion on a non-strict basis. 

====Status Report====

* <eiffel>empty</eiffel> is <eiffel>True</eiffel> if the <eiffel>INTERVAL</eiffel> is empty, i.e., if the value of the start bound is equal to the value of the end bound.
* <eiffel>has</eiffel>, <eiffel>strict_before</eiffel>, <eiffel>strict_after</eiffel>, <eiffel>before</eiffel>, and <eiffel>after</eiffel> test the position of an element relative to the current interval.

====Element change====

<eiffel>set_start_bound</eiffel> and <eiffel>set_end_bound</eiffel> are available to change the bounds. <eiffel>set_start_bound</eiffel> and <eiffel>set_end_bound</eiffel> create new objects from their arguments (twins), so that if these bounds are altered later, the original objects which had been referenced as arguments will not change.

====Operations====

* <eiffel>union</eiffel> provides a new <eiffel>INTERVAL</eiffel> that includes the entire range covered by both the target <eiffel>INTERVAL</eiffel> and an argument <eiffel>INTERVAL</eiffel> which intersects the target. 
* <eiffel>intersection</eiffel> returns a new <eiffel>INTERVAL</eiffel> that represents the area common to both the target <eiffel>INTERVAL</eiffel> and the argument <eiffel>INTERVAL</eiffel>. <eiffel>intersection</eiffel> returns <eiffel>Void</eiffel> if the target and argument do not intersect.
* <eiffel>gather</eiffel> requires that a target and argument <eiffel>INTERVAL</eiffel> have a common bound (i.e., <eiffel> int_1.meets (int_2) </eiffel> is <eiffel>True</eiffel>) and then returns a new <eiffel>INTERVAL</eiffel> with the union of the two.




