From 4d639d0bc2b9ad3432cf2287fe4d3998afebb932 Mon Sep 17 00:00:00 2001 From: halw Date: Sat, 1 Nov 2008 17:21:42 +0000 Subject: [PATCH] Author:halw Date:2008-11-01T17:21:42.000000Z git-svn-id: https://svn.eiffel.com/eiffel-org/trunk@101 abb3cda0-5349-4a8f-a601-0c33ac3a8c38 --- .../eiffeltime/eiffeltime-tutorial/duration.wiki | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/documentation/current/solutions/dates-and-times/eiffeltime/eiffeltime-tutorial/duration.wiki b/documentation/current/solutions/dates-and-times/eiffeltime/eiffeltime-tutorial/duration.wiki index a2a5159c..0c303625 100644 --- a/documentation/current/solutions/dates-and-times/eiffeltime/eiffeltime-tutorial/duration.wiki +++ b/documentation/current/solutions/dates-and-times/eiffeltime/eiffeltime-tutorial/duration.wiki @@ -5,7 +5,7 @@ The classes dealing with duration inherit DURATION, which inherits GROUP_ELEMENT and PART_COMPARABLE. An instance of TIME_DURATION, DATE_DURATION, or DATE_TIME_DURATION is an element of a group, i.e. there is a zero and addition operations (infix +, infix -, prefix +, and prefix -). Duration is used as an amount of time, without link to an origin. It may be added to the respective absolute notion (TIME + TIME_DURATION is possible, but not TIME + DATE_TIME_DURATION nor DATE_TIME + TIME_DURATION ... see classes TIME, DATE, and DATE_TIME). -Attributes are allowed to take negative values or values which do not fall in the expected range (e.g., hour = -1, minute = 75, day = 40...). However, features are available in each class to convert instances into the usual format: functions canonical and to_canonical are present in each class. An instance is canonical (canonical = True) if the values of its attributes fall into the usual range. For example, an instance of TIME_DURATION such as 12:-10:60 is not canonical. to_canonical will return 11:51:0. These features are also present in DATE_DURATION and DATE_TIME_DURATION.The order is partially implemented. TIME_DURATION has a complete order whereas DATE_DURATION and DATE_TIME_DURATION are more specific. +Attributes are allowed to take negative values or values which do not fall in the expected range (e.g., hour = -1, minute = 75, day = 40...). However, features are available in each class to convert instances into the usual format: functions canonical and to_canonical are present in each class. An instance is canonical (i.e., when canonical = True) if the values of its attributes fall into the usual range. For example, an instance of TIME_DURATION such as 12:-10:60 is not canonical. to_canonical will return 11:51:0. These features are also present in DATE_DURATION and DATE_TIME_DURATION.The order is partially implemented. TIME_DURATION has a complete order whereas DATE_DURATION and DATE_TIME_DURATION are more specific. ==TIME_DURATION== @@ -43,9 +43,11 @@ Durations may be canonical or not canonical (tested using the BOOLEANdefinite which returns a BOOLEAN, is true for definite duration and false otherwise. An instance is definite if and only if its attributes month and year are 0. Then only the number of days is used. Relative (non definite) durations have their attributes year, month, and day meaningful but it is then impossible to compare them to each other (is one month greater than 30 days?, is one year greater than 365 days?). The main difference appears when a duration is added to a date. In the case of a definite duration, there is no ambiguity. A given number of days are added to the date, taking care of the calendar. In the other case, the result is relative to the origin date. For example, a one month duration may be equal to 28 days if the date is in February or 31 days if the date is in August. A duration becomes definite when its attributes year and month become 0. However it is possible to deal with instances of DATE_DURATION without taking care of this distinction. +The ''definite'' ones and the ''relative'' ones. The function definite which returns a BOOLEAN, is true for definite duration and false otherwise. An instance is definite if and only if its attributes month and year are 0. Then only the number of days is used. Relative (non definite) durations allow their attributes year, month, and day to have meaningful values, but it is then impossible to compare them to each other (is one month greater than 30 days?, is one year greater than 365 days?). + +The distinction between definite and relative date duration matters when a duration is added to a date. In the case of a definite duration, there is no ambiguity. A given number of days is added to the date. In the case of a relative date duration, the result is relative to the origin date. For example, a one month duration may be equal to 28 days if the date is in February or 31 days if the date is in August. A duration becomes definite when its attributes year and month become 0. However it is possible to deal with instances of DATE_DURATION without taking care of this distinction. ===Relative DATE_DURATION=== @@ -87,7 +89,8 @@ Features set_day, set_month, and set_y ====Conversion==== * to_canonical is used to get a new duration equivalent to the current one and canonical. It needs an argument from class DATE, 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 of DATE_TIME_DURATION. It will have the same date of the current duration and time set to zero. +* 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 of DATE_TIME_DURATION. It will have the same date of the current duration and time set to zero. ==DATE_TIME_DURATION== @@ -113,7 +116,7 @@ The rules are the same than those for DATE_DURATION. Features < ====Element change==== -It is possible to change reference of time and date with the features set_time and set_date. To change only one element (for example hour), features from TIME_DURATION or DATE_DURATIONhave to be used. +It is possible to change reference of time and date with the features set_time and set_date. To change only one element (for example hour), features from TIME_DURATION or DATE_DURATION have to be used. ====Operation==== * DATE_TIME_DURATION inherits from GROUP_ELEMENT. infix and prefix +, infix and prefix - are available to compose instances to each other.