timeRelative
class represents relative times.holidays
slot of the relative time object is used
to define which dates besides weekends are not business days;
these dates are taken in theholidays
slots time zone."a"
flag in the field,
the smaller units of time are not changed; for example, when adding days,
the time of day stays the same, and when adding months,
the day of the month and the time of day stay the same.timeRelative
class stores a representation of relative
times. Unlike timeSpan
, which stores absolute
time differences, the timeRelative
class stores relative times
in units such as weekdays, months, and business days, whose
absolute time value depends on the timeDate
object with which they are
combined.Both timeRelative
and timeSpan
extend the
virtual timeInterval
class.
The Data
slot in a timeRelative
object holds a character
vector that represents the relative time. Each element of the
vector is a character string consisting of whitespace-separated
fields in the following form:
"[+-][a]#abb"
}
This vector is composed of a required sign (either "+"
or "-"
),
followed by an optional "a"
that, if present, means to align the result
(see below; it is also possible to specify 0
if aligning),
followed by a positive integer and one of the relative time field abbreviations
from the following list:
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
When relative time objects are added to time/date objects,
the fields from an element of the relative time object are parsed
and added to the corresponding element of the time/date object
from left to right. (If either the time/date object or the relative time object
is shorter than the other, it is reused cyclically in the standard S manner.)
For example, for a date/time of May 13, 2012 4:32 PM (a Sunday),
the relative time element is: "+a3hr +12hr -1day"
.
You can add relative time objects to time/date objects, or you can
subtract relative time objects from time/date objects. Also, you can add
them to each other, subtract them from each other, or multiplt them by integers.
When they are negated, the sign of each field is reversed.
When they are added together, they are concatenated,
so that if x
is a time/date object
and y
and z
are relative time objects,
(x + y) + z == x + (y + z)
;
however, y + z
is not the same as z + y
.
timeDate
class, timeSpan
class,
timeRelative
function.