Author:halw

Date:2008-11-03T23:31:09.000000Z


git-svn-id: https://svn.eiffel.com/eiffel-org/trunk@104 abb3cda0-5349-4a8f-a601-0c33ac3a8c38
This commit is contained in:
halw
2008-11-03 23:31:09 +00:00
parent b39c257523
commit 095e0c7e51
3 changed files with 25 additions and 25 deletions

View File

@@ -13,19 +13,19 @@ The default way to compare absolute objects is to compare their respective durat
====Creation====
There are three ways to create an instance of the class <eiffel>TIME</eiffel>: by choosing the time (make), by getting the time from the system (<eiffel>make_now</eiffel>), or by choosing the number of seconds elapsed from the origin (<eiffel>make_by_seconds</eiffel>). The arguments of <eiffel>make</eiffel> and <eiffel>make_by_seconds</eiffel> have to respect the range of a day (see preconditions).
There are three ways to create an instance of the class <eiffel>TIME</eiffel>: by choosing the time (<eiffel>make</eiffel>), by getting the time from the system (<eiffel>make_now</eiffel>), or by choosing the number of seconds elapsed from the origin (<eiffel>make_by_seconds</eiffel>). The arguments of <eiffel>make</eiffel> and <eiffel>make_by_seconds</eiffel> have to respect the range of a day (see preconditions).
====Origin and cyclic representation====
The origin is 0 hour 0 minute and 0 second. Notion of time is relative to a day in a cyclic representation: days begin at 0:0:0 and end at 23:59:59. If a second is added to 23:59:59 then the result will be 0:0:0. Subtracting a minute to 0:0:0 will yield 23:59:0.
The origin is 0 hour 0 minute and 0 second. Notion of time is relative to a day in a cyclic representation: days begin at 0:0:0 and end at 23:59:59. If a second is added to 23:59:59 then the result will be 0:0:0. Subtracting a minute from 0:0:0 will yield 23:59:0.
====Comparison====
Instances of [[ref:libraries/time/reference/time_chart|TIME ]] may be compared. Functions <, +, >, and >= are available. Function <eiffel>is_equal</eiffel> (or <eiffel>~</eiffel>) can be used to test object equality, while <eiffel>=</eiffel> will compare references.
Instances of [[ref:libraries/time/reference/time_chart|TIME ]] may be compared. Functions <eiffel><</eiffel>, <eiffel>+</eiffel>, <eiffel>></eiffel>, and <eiffel>>=</eiffel> are available. Function <eiffel>is_equal</eiffel> (or <eiffel>~</eiffel>) can be used to test object equality, whereas <eiffel>=</eiffel> will compare references.
====Measurement====
The duration linked to an instance of [[ref:libraries/time/reference/time_chart|TIME]] (attribute <eiffel>duration</eiffel>) is an instance of [[ref:libraries/time/reference/time_duration_chart|TIME_DURATION]] . It is the duration from the origin until the current time. The function seconds returns the number of seconds since the origin. This function may be useful to get the number of seconds between two events.The feature - creates an interval between two instances of <eiffel>TIME</eiffel>. The duration of this interval is given by the function duration. However, this duration is not canonical (See [[Duration|Duration]] for precisions). In <eiffel>TIME</eiffel>, the feature <eiffel>relative_duration</eiffel> returns the same duration, but more efficiently and also it is canonical.
The duration linked to an instance of [[ref:libraries/time/reference/time_chart|TIME]] (query <eiffel>duration</eiffel>) results in an instance of [[ref:libraries/time/reference/time_duration_chart|TIME_DURATION]] . It is the duration from the origin until the current time. The query <eiffel>seconds</eiffel> returns the number of seconds since the origin. This query may be useful to get the number of seconds between two events.The feature <eiffel>-</eiffel> creates an interval between two instances of <eiffel>TIME</eiffel>. The duration of this interval is given by the function <eiffel>duration</eiffel>. However, this duration is non-canonical (See [[Duration|Duration]] for precisions). In <eiffel>TIME</eiffel>, the feature <eiffel>relative_duration</eiffel> returns the same duration, but more efficiently and also it is canonical.
====Operations====
* Set directly <eiffel>hour</eiffel>, <eiffel>minute</eiffel>, and <eiffel>second</eiffel> with <eiffel>set_hour</eiffel>, <eiffel>set_minute</eiffel>, and <eiffel>set_second</eiffel>. Arguments must satisfy the rules of creation.

View File

@@ -123,7 +123,7 @@ The rules are the same than those for <eiffel>DATE_DURATION</eiffel>. Features <
It is possible to change reference of time and date with the features <eiffel>set_time</eiffel> and <eiffel>set_date</eiffel>. To change only one element (for example <eiffel>hour</eiffel>), features from <eiffel>TIME_DURATION</eiffel> or <eiffel>DATE_DURATION</eiffel> have to be used.
====Operation====
* <eiffel>DATE_TIME_DURATION</eiffel> inherits from <eiffel>GROUP_ELEMENT</eiffel>. infix and prefix <eiffel>+</eiffel>, infix and prefix <eiffel>-</eiffel> are available to compose instances to each other.
* <eiffel>DATE_TIME_DURATION</eiffel> inherits from <eiffel>GROUP_ELEMENT</eiffel>. <eiffel>infix</eiffel> and <eiffel>prefix</eiffel> <eiffel>+</eiffel>, <eiffel>infix</eiffel> and <eiffel>prefix</eiffel> <eiffel>-</eiffel> are available to compose instances to each other.
* Only <eiffel>day_add</eiffel> is present. To add only one element, features from <eiffel>TIME_DURATION</eiffel> or <eiffel>DATE_DURATION</eiffel> have to be used.
====Conversion====

View File

@@ -1,43 +1,43 @@
[[Property:title|Interval]]
[[Property:weight|2]]
[[Property:uuid|d33d0216-fa71-60dc-f3b0-61ff42d621e6]]
Class <eiffel>INTERVAL</eiffel> deals with intervals between two instances of the same class which conform to<eiffel> ABSOLUTE</eiffel> ( <eiffel>DATE</eiffel>, <eiffel>TIME</eiffel>, <eiffel>DATE_TIME</eiffel>). The notions of interval is directly linked with the notion of order.
The <eiffel>start_bound</eiffel> must be before the <eiffel>end_bound</eiffel>.
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> ( <eiffel>DATE</eiffel>, <eiffel>TIME</eiffel>, <eiffel>DATE_TIME</eiffel>).
====Creation====
The features <eiffel>make</eiffel>, <eiffel>set_start_bound</eiffel> and <eiffel>set_end_bound</eiffel> take clones of their arguments, so that if these arguments are changed, the interval previously created is not.
It would have been possible to create intervals with references to date or time, but a modification of the dates would have been effective in the interval so that only the invariant would have been able to check if the <eiffel>start_bound</eiffel> is still before the <eiffel>end_bound</eiffel>.
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 measure of intervals is made by duration: the result is an instance of the class <eiffel>DURATION</eiffel>. However, as <eiffel>DURATION</eiffel> is the common parent of <eiffel>TIME_DURATION</eiffel>, <eiffel>DATE_DURATION</eiffel>, and <eiffel>DATE_TIME_DURATION</eiffel>, it does not have many features available. Some features in class <eiffel>TIME</eiffel>, <eiffel>DATE</eiffel>, and <eiffel>DATE_TIME</eiffel> return the same result and are more efficient to use. <eiffel>DURATION</eiffel> has to be use as the last solution.
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====
It includes intersection, inclusion and a special comparison.
* <eiffel>is_equal</eiffel> is present and compare values, not references.
* Feature <eiffel>intersects</eiffel> returns the mathematical result of the intersection of two intervals.
* <eiffel>is_strict_included_by</eiffel>, <eiffel>strict_includes</eiffel>, <eiffel>is_included_by</eiffel> and <eiffel>includes</eiffel> are connected to the same notion of inclusion.
* <, + > and >= use a special rule to compare intervals. int1 < int2 is true if int1 starts and ends strictly before int2. The other features use the <eiffel>same rule</eiffel> and<eiffel> is_equal</eiffel> if needed.
* <eiffel>overlaps</eiffel> looks like <eiffel>intersects</eiffel> but the argument has to be after the current interval. <eiffel>is_overlapped</eiffel> is the opposite.
* <eiffel>meets</eiffel> and <eiffel>is_met</eiffel> are used to test if two intervals have a common bound.
* <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> 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====
The main part of the functions need an argument from the same generic type and return a <eiffel>BOOLEAN</eiffel> value.
* <eiffel>empty</eiffel> tests if the bounds are equal.
* <eiffel>has</eiffel>,<eiffel> strict_before</eiffel>, <eiffel>strict_after</eiffel>,<eiffel> before</eiffel> and <eiffel>after</eiffel> test the position of an element relatively to the current interval.
* <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> 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> and <eiffel>intersection</eiffel> are the mathematical functions. <eiffel>gather</eiffel> requires that two intervals meet each other and then yields the union.
* <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.