ceiling_date seems to give erroneous results. Consider the following example:
library(lubridate)
packageVersion( 'lubridate')
# [1] 1.3.3
Sys.setenv( TZ="UTC" )
dt <- ymd( "20120930", "20121001", "20121002", "20121101" )
floor_date( dt, "month" )
# [1] "2012-09-01 UTC" "2012-10-01 UTC" "2012-10-01 UTC" "2012-11-01 UTC"
ceiling_date( dt, "month" )
# [1] "2012-10-01 UTC" "2012-10-01 UTC" "2012-11-01 UTC" "2012-11-01 UTC"
I expect the second result to be "2012-11-01 UTC", i.e. like the third. This is consistently wrong as seen by the fourth argument.
The problem appears to be with the following expression in ceiling_date:
y <- floor_date(x - eseconds(1), unit)
I don't believe that there is a reason to subtract a second. Changing this to:
y <- floor_date( x, unit )
fixes the issue.
Also, I realize that the ship has probably sailed on this, but shouldn't the ceiling for a month be the last second in the month, e.g. 2012-10-31 12:59:59 rather than the first second of the following month?
ceiling_dateseems to give erroneous results. Consider the following example:I expect the second result to be "2012-11-01 UTC", i.e. like the third. This is consistently wrong as seen by the fourth argument.
The problem appears to be with the following expression in
ceiling_date:y <- floor_date(x - eseconds(1), unit)I don't believe that there is a reason to subtract a second. Changing this to:
y <- floor_date( x, unit )fixes the issue.
Also, I realize that the ship has probably sailed on this, but shouldn't the ceiling for a month be the last second in the month, e.g.
2012-10-31 12:59:59rather than the first second of the following month?