Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed bug in ceiling_date so it now correctly handles unit = 'seconds'

  • Loading branch information...
commit 044a7a3899ef90f76b2a7c4d689a370dd61c0220 1 parent 6942c68
@garrettgman garrettgman authored
Showing with 6 additions and 2 deletions.
  1. +6 −2 R/round.r
View
8 R/round.r
@@ -74,11 +74,15 @@ floor_date <- function(x, unit = c("second","minute","hour","day", "week", "mont
#' # "2010-01-01 CST"
ceiling_date <- function(x, unit = c("second","minute","hour","day", "week", "month", "year")) {
unit <- match.arg(unit)
-
+
+ if (unit == "second") {
+ second(x) <- ceiling(second(x))
+ return(x)
+ }
+
y <- floor_date(x - seconds(1), unit)
switch(unit,
- second = second(y) <- second(y) + 1,
minute = minute(y) <- minute(y) + 1,
hour = hour(y) <- hour(y) + 1,
day = yday(y) <- yday(y) + 1,
Please sign in to comment.
Something went wrong with that request. Please try again.