Mathematical operations with 'timeDate' objects
methodsmathOps.Rd
Functions for mathematical and logical operations on "timeDate"
objects.
Arguments
 e1, e2

objects of class
"timeDate"
. In the case of addition and subtraction one of them may be of classnumeric
, specifying the number of seconds to add or subtract.
Details
Group "Ops"
represents the binary mathematical operators.
Methods are defined for such operations when one or both arguments are
from class "timeDate"
.
Operations that don't make sense, such as addition of two
"timeDate"
objects, throw error.
The plus operator "+"
performs arithmetic "+" operation on
"timeDate"
objects,
and the minus operator ""
returns a
difftime
object if both arguments e1
and e2
are "timeDate"
objects, or returns a "timeDate"
object
e2
seconds earlier than e1
.
Value
addition of numeric to "timeDate"
returns "timeDate"
,
subtraction of numeric from "timeDate"
returns "timeDate"
,
subtraction of two "timeDate"
objects returns "difftime"
,
other operations between two "timeDate"
objects are applied to
the underlying times (slot "Date"
). The result of that
operation is converted to "timeDate"
if it represents a time
and returned as is otherwise.
Examples
## Create Character Vectors:
dts = c("19890928", "20010115", "20040830", "19900209")
dts
#> [1] "19890928" "20010115" "20040830" "19900209"
tms = c( "23:12:55", "10:34:02", "08:30:00", "11:18:23")
tms
#> [1] "23:12:55" "10:34:02" "08:30:00" "11:18:23"
## "+/" 
# Add One Day to a Given timeDate Object:
GMT = timeDate(dts, zone = "GMT", FinCenter = "GMT")
GMT
#> GMT
#> [1] [19890928] [20010115] [20040830] [19900209]
ZUR = timeDate(dts, zone = "GMT", FinCenter = "Europe/Zurich")
ZUR
#> Europe/Zurich
#> [1] [19890928 01:00:00] [20010115 01:00:00] [20040830 02:00:00]
#> [4] [19900209 01:00:00]
GMT + 24*3600
#> GMT
#> [1] [19890929] [20010116] [20040831] [19900210]
ZUR[2]  ZUR[1]
#> Time difference of 4127 days