lubridate (version 1.1.0)

int_shift: Shift an interval along the timeline

Description

Shifts the start and end dates of an interval up or down the timeline by a specified amount. Note that this may change the exact length of the interval if the interval is shifted by a Period object. Intervals shifted by a Duration or difftime object will retain their exact length in seconds.

Usage

int_shift(int, by)

Arguments

int
An interval object
by
A period or duration object

Value

  • An interval object

See Also

int_flip, int_start, int_end

Examples

Run this code
int <- new_interval(ymd("2001-01-01"), ymd("2002-01-01"))
# 2001-01-01 UTC--2002-01-01 UTC
int_shift(int, new_duration(days = 11))
# 2001-01-12 UTC--2002-01-12 UTC
int_shift(int, new_duration(hours = -1))
# 2000-12-31 23:00:00 UTC--2001-12-31 23:00:00 UTC

Run the code above in your browser using DataCamp Workspace