Product SiteDocumentation Site

5.4.3.12. Arithmetic Methods


>>-arithmetic_operator(argument)-------------------------------><

Note

For the prefix + operators, omit the parentheses and argument.
Returns the result of performing the specified arithmetic operation on the receiver TimeSpan object. Depending on the operation, the argument be either a TimeSpan object, a DateTime object, or a number. See the description of the individual operations for details. The arithmetic_operator can be:
+
Addition. If argument is a DateTime object, the TimeSpan is added to the DateTime object, returning a new DateTime instance. Neither the receiver TimeSpan or the argument DateTime object is altered by this operation. The TimeSpan may be either positive or negative.
If argument is a TimeSpan object, the two TimeSpans are added together, and a new TimeSpan instance is returned. Neither the TimeSpan object is altered by this operation.
-
Subtraction. The argument must be a TimeSpan object. The argument TimeSpan is subtracted from the receiver TimeSpan and a new TimeSpan instance is returned. Neither the TimeSpan object is altered by this operation.
*
Multiplication. The argument must be a valid Rexx number. The TimeSpan is multiplied by the argument value, and a new TimeSpan instance is returned. The receiver TimeSpan object is not altered by this operation.
/
Division. The argument must be a valid Rexx number. The TimeSpan is divided by the argument value, and a new TimeSpan instance is returned. The receiver TimeSpan object is not altered by this operation. The / operator and % produce the same result.
%
Integer Division. The argument must be a valid Rexx number. The TimeSpan is divided by the argument value, and a new TimeSpan instance is returned. The receiver TimeSpan object is not altered by this operation. The / operator and % produce the same result.
//
Remainder Division. The argument must be a valid Rexx number. The TimeSpan is divided by the argument value and the division remainder is returned as a new TimeSpan instance. The receiver TimeSpan object is not altered by this operation.
Prefix -
The TimeSpan is negated, returning a new TimeSpan instance. The receiver TimeSpan is not altered by this operation.
Prefix +
Returns a new instance of the TimeSpan object with the same time value.

Example 5.189. Class TIMESPAN


t1 = .timespan~fromHours(1)
t2 = t1 * 2
-- displays "01:00:00.000000 02:00:00.000000 03:00:00.000000"
say t1 t2 (t1 + t2)