Class DATETIME - arithmetic


t = .dateTime~new~timeOfDay  -- returns TimeSpan for current time.
say t                        -- displays "11:27:12.437000", perhaps
d = .dateTime~new(2010, 4, 11)  -- creates new date

future = d + t               -- adds timespan to d
say future                   -- displays "2010-04-11T11:27:12.437000"
                             -- "real" start of next century
nextCentury = .dateTime~new(2101, 1, 1)
                             -- displays "34060.12:25:49.922000", perhaps
say "The next century starts in" (nextCentury - .dateTime~new)

Read Me - Common Public License V1.0 - Copyright Notice(©)

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 DateTime object. Depending on the operation, the [argument] be either a TimeSpan object or a DateTime object. See the description of the individual operations for details. The [arithmetic_operator] can be:

+ + method method+ Addition. Adds a TimeSpan to the DateTime object, returning a new DateTime instance. The receiver DateTime object is not changed. The TimeSpan may be either positive or negative.
- - method method- Subtraction. If argument is a DateTime object, the two times are subtracted, and a TimeSpan object representing the interval between the two times is returned. If the receiver DateTime is less than the argument argument DateTime, a negative TimeSpan interval is returned. The receiver DateTime object is not changed. If argument is a TimeSpan object, subtracts the TimeSpan from the DateTime object, returning a new DateTime instance. The receiver DateTime object is not changed. The TimeSpan may be either positive or negative.
Prefix - methodprefix - A prefix - operation on a DateTime object will raise a SYNTAX error condition.
Prefix + methodprefix + Returns a new instance of the DateTime object with the same time value.

Read Me - Common Public License V1.0 - Copyright Notice(©)