Create an ordered two-element POSIXct time range from start and end
datetime values.
timeRange(
starttime = NULL,
endtime = NULL,
timezone = NULL,
unit = "sec",
ceilingStart = FALSE,
ceilingEnd = FALSE
)Desired start datetime.
Desired end datetime.
Olson timezone used to interpret incoming datetimes.
Unit used for rounding. Passed to lubridate::floor_date() or
lubridate::ceiling_date().
Logical specifying whether to round the start time up instead of down.
Logical specifying whether to round the end time up instead of down.
Two-element POSIXct vector ordered from earliest to latest.
Input values are converted with parseDatetime() using the required
timezone argument. The resulting start and end times are sorted so the
earlier time is always returned first.
By default, both times are rounded down with lubridate::floor_date() using
the requested unit. Set ceilingStart = TRUE or ceilingEnd = TRUE to
round either endpoint up with lubridate::ceiling_date() instead.
When startdate or enddate are already POSIXct values, they are first
converted to timezone with lubridate::with_tz() without changing the
represented instant in time.
timeRange(
starttime = "2019-01-08 10:12:15",
endtime = 20190109102030,
timezone = "UTC"
)
#> [1] "2019-01-08 10:12:15 UTC" "2019-01-09 10:20:30 UTC"
timeRange(
starttime = "2019-01-08 10:12:15",
endtime = "2019-01-09 10:20:30",
timezone = "UTC",
unit = "hour"
)
#> [1] "2019-01-08 10:00:00 UTC" "2019-01-09 10:00:00 UTC"