duration_floor()
rounds a duration down to a multiple of the specified
precision
.
duration_ceiling()
rounds a duration up to a multiple of the specified
precision
.
duration_round()
rounds up or down depending on what is closer,
rounding up on ties.
duration_floor(x, precision, ..., n = 1L) duration_ceiling(x, precision, ..., n = 1L) duration_round(x, precision, ..., n = 1L)
x 
A duration. 

precision 
A precision. One of:

...  These dots are for future extensions and must be empty. 
n 
A positive integer specifying the multiple of 
x
rounded to the precision
.
You can floor calendrical durations to other calendrical durations, and chronological durations to other chronological durations, but you can't floor a chronological duration to a calendrical duration (such as flooring from day to month). For more information, see the documentation on the duration helper page.
#> <duration<day>[2]> #> [1] 0 1duration_ceiling(x, "day")#> <duration<day>[2]> #> [1] 1 2# Can't floor from a chronological duration (seconds) # to a calendrical duration (months) try(duration_floor(x, "month"))#> Error : Can't floor from a chronological precision (second) to a calendrical precision (month).# Every 2 days, using an origin of day 0 y < duration_seconds(c(0, 86400, 86400 * 2, 86400 * 3)) duration_floor(y, "day", n = 2)#> <duration<day>[4]> #> [1] 0 0 2 2# Shifting the origin to be day 1 origin < duration_days(1) duration_floor(y  origin, "day", n = 2) + origin#> <duration<day>[4]> #> [1] 1 1 1 3# Rounding will round ties up half_day < 86400 / 2 half_day_durations < duration_seconds(c(half_day  1, half_day, half_day + 1)) duration_round(half_day_durations, "day")#> <duration<day>[3]> #> [1] 0 1 1#> <duration<year>[3]> #> [1] 0 1 2duration_floor(x, "quarter")#> <duration<quarter>[3]> #> [1] 0 5 8