 Version
 18.01 (released) ...
Duration
 Contents
 TIME_DURATION
 DATE_DURATION
 DATE_TIME_DURATION
The classes
The classes dealing with duration inherit from
Duration is used as an amount of time, without link to an origin. It may be added to the respective absolute notion So,
Attributes of durations are allowed to take values which do not fall in the expected range, even negative values (e.g.,
An instance is canonical if the values for all of its relevant attributes fall into the specific ranges defined for each type of duration, documented in sections below (for example, for a canonical instance of
Ordering is partial for
TIME_DURATION
Creation
Instances can be created either by specifying a value for each of the attributes
Access
The query
The total number of seconds in the current duration can be obtained by applying the query
Comparison
Instances of <
, >
, <=
, and >=
are available. The
Element change
Set
Operations
 Add hours, minutes and seconds with features
hour_add ,minute_add andsecond_add . 
infix + andinfix  are available for producing sums and differences of durations. 
prefix  is available for producing the inverse of a duration.
Conversion
Two features provide a conceptual link with the notion of day:
 The first,
to_days returns the number of days equivalent to the current duration. For example, a duration such as 23:60:0 is equivalent to one day. For negative duration, the result is never 0. 1 hour is equivalent to 1 day (i.e. the result ofto_days is 1).  The second is
time_modulo_day . This query returns an instance ofTIME_DURATION . The result represents the difference between the current duration and the number of days yielded byto_days . It implies that the result is always positive and less than one day.
Durations may be in canonical or noncanonical form. This can be tested using the
 in the case of a positive duration (> zero), all of the three features have to be positive or 0,
minute andsecond less than 60.  in the case of a negative duration (< zero), all of the three features have to be negative or 0,
minute andsecond strictly greater than 60.
 in the case of a positive duration (> zero), all of the three features have to be positive or 0,
Two queries help you work with canonical form:
 The value of the query
canonical isTrue if duration is in canonical form.  The query
to_canonical yields a new, canonicalTIME_DURATION equivalent to the duration to which it is applied.
DATE_DURATION
An instance is definite if and only if its attributes
Relative (nondefinite) durations allow their attributes
The distinction between definite and relative date duration makes a difference when a duration is added to a date. In the case of a definite
About relative DATE_DURATIONs
Relative durations cannot be compared with any other durations (including zero). This is because of the complexities of the Gregorian calendar. If we consider how many days there are in a duration of one month, we cannot point to a specific integer value that will be correct in all cases ... it depends upon which month we are considering ... and in some cases whether it is a leap year.
If a comparison (>
or <
) is applied in a state in which either the current instance or the argument or both are relative durations, the result will be always
We are able to determine if two durations have equal value by applying the feature
When adding a relative
Nevertheless, there is a way to compare relative durations: a relative date_duration may be canonical. It means that the duration has its attributes
 If the origin date is 01/15 (15th of January), the final date is 02/14. We cannot convert 30 days into 1 month in this case. The duration is canonical.
 If the origin date is 04/15 (15th of April), the final date is 05/15. The duration is not canonical since it is possible to convert days into 1 month. The origin date is used to determine whether the duration is positive or not. If the final date is after the origin date the duration is positive, otherwise it is negative. That does not mean we can compare it to zero, that is only used to determine the sign of the canonical standard. If the duration is negative, it is canonical only if all the attributes are negative.
A way to compare two relative durations is to make them canonical from the same date, and then to compare the fields. It is the same as adding the durations to the same date, and to compare the final dates to each other.
About definite DATE_DURATIONs
Definite durations are characterized by the attribute
The number of days between an origin date and the result of (date + duration) does not depend on the origin date. It is possible to compare definite date_duration to each other.The order is the one of day.
A definite duration may be canonical or not. It is canonical if the number of day is small enough.
General description
Creation
Two creation features are available:
Comparison
Features <
, >
, <=
, and >=
are available. If both instances are definite, numbers of days are compared. If one of them is nondefinite, the result is False.
Element change
Features
Operations
 Add years, months and days with features
year_add ,month_add , andday_add . 
DATE_DURATION inherits fromGROUP_ELEMENT .infix andprefix + ,infix andprefix  are available to compose instances of each other.
Conversion

to_canonical is used to get a new duration equivalent to the current one and canonical. It needs an argument from classDATE , which is the origin of calculations. 
to_definite is used to get a new duration equivalent to the current one and definite. As with the previous feature, one argument is needed. 
to_date_time is used to get an instance ofDATE_TIME_DURATION . It will have the same date of the current duration and time set to zero.
DATE_TIME_DURATION
There are, as in
Creation
There are still several ways to create an instance:
 Provide values for all the components of date and time (
make ).  Provide a value for day and values for all the components of time. The instance is then definite (
make_definite ).  by gathering an instance of
DATE with an instance ofTIME (make_by_date_time ). This feature copies the references of its arguments, so that if the time (or the date) is changed, the instance previously initialized will be also changed. If this effect has to be avoided, the use of twins is required.  by encapsulating an instance of
DATE (make_by_date ). The attributetime is set to zero, i.e. 0:0:0. The attributedate is set with the same reference than the argument.
Access
Comparison
The rules are the same than those for <
, >
, <=
, and >=
are available. If both instances are definite, numbers of days are compared. If one of them is nondefinite, the result is False.
Element change
It is possible to change reference of time and date with the features
Operations

DATE_TIME_DURATION inherits fromGROUP_ELEMENT .infix andprefix + ,infix andprefix  are available to compose instances to each other.  Only
day_add is present. To add only one element, features fromTIME_DURATION orDATE_DURATION have to be used.
Conversion

canonical andto_canonical are available in the class. To be canonical an instance of the class must have its attributestime anddate canonical. Then time must have the same sign than the one of the current duration. The sign of the current instance is determined by adding it to the argument (fromDATE_TIME ). That will yield a final date. If this final date is after the origin (= the argument), the current duration is considered positive. Otherwise, it is considered negative. Finally time must be less than one day (if positive) or more than minus one day (if negative).to_canonical returns a duration equivalent to the current one (for the argument) and canonical. 
time_to_canonical looks liketo_canonical but focuses mainly on time. It requires a definite duration so that it is possible to compare it to zero. It yields a definite duration equivalent to the current one with a canonical time.hour is then cut so that it stands in the range of one day (0 to 23 if positive and 23 to 0 if negative). The attributeday is also modified to keep the result equivalent to the current duration.time_to_canonical does not need any argument because only time and day are modified.