| mt_time-arithmetic | R Documentation |
mt_time)Time points, linear (e.g. yearmonth()) or located cyclical (e.g.
month_of_year(Sys.Date())), support:
Shifts: x + d, x - d and d + x shift by a duration(). Time
points that don't exist (e.g. 31 January plus one month) are resolved
with the mixtime.on_invalid option; see time_shift().
Shifts by chronons: x + n and x - n shift by n of the time
points' own chronon.
Differences: a - b is a duration() in their finest common
chronon.
Located cyclical time shifts its underlying time, and its position within the cycle follows. For underspecified cyclical time, see mt_cyclical_free-arithmetic.
A discrete time point spans its whole chronon, so shifting by a duration finer than its chronon, or taking differences between discrete time points of different chronons, is an error. Any other combination, such as adding two time points or subtracting a time point from a duration, is also an error.
## S4 method for signature 'mt_time'
e1 + e2
## S4 method for signature 'mt_time'
e1 - e2
e1, e2 |
Operands, at least one a time point ( |
A time point vector for shifts, a duration (mt_duration) for differences.
x <- yearmonth("2024-01")
x + months(2)
x + 0:3
yearmonth("2024-05") - x
date("2024-01-31") + months(1)
month_of_year(yearmonth("2024-11")) + 3L
try(date("2024-03-15") + hours(3))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.