Mathematical operations with 'timeDate' objects
methods-mathOps.Rd
Functions for mathematical and logical operations on "timeDate"
objects.
The functions are:
Ops,timeDate | Group 'Ops' generic functions for "timeDate" objects, |
+,timeDate | Performs arithmetic + operation on "timeDate" objects, |
-,timeDate | Performs arithmetic - operation on "timeDate" objects. |
Arguments
- e1, e2
usually objects of class
"timeDate"
, in the case of addition and subtractione2
may be of classnumeric
.
Value
Ops.timeDate
these are functions for mathematical operations. Group Ops
are
generic functions which manage mathematical operations.
+.timeDate
-.timeDate
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
.
Examples
## Create Character Vectors:
dts = c("1989-09-28", "2001-01-15", "2004-08-30", "1990-02-09")
dts
#> [1] "1989-09-28" "2001-01-15" "2004-08-30" "1990-02-09"
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] [1989-09-28] [2001-01-15] [2004-08-30] [1990-02-09]
ZUR = timeDate(dts, zone = "GMT", FinCenter = "Europe/Zurich")
ZUR
#> Europe/Zurich
#> [1] [1989-09-28 01:00:00] [2001-01-15 01:00:00] [2004-08-30 02:00:00]
#> [4] [1990-02-09 01:00:00]
GMT + 24*3600
#> GMT
#> [1] [1989-09-29] [2001-01-16] [2004-08-31] [1990-02-10]
ZUR[2] - ZUR[1]
#> Time difference of 4127 days