Enrich `floor_date` function
ywhcuhk opened this issue · comments
@matthieugomez Could you add an additional parameter that determines start or end of the unit specified in floor_date
function?
An example would be:
d = as.Date('1992-03-15')
floor_date(d, 'month', 'end') # gives 1992-03-31
floor_date(d, 'month', 'start') # gives 1992-03-01
Thanks!
The function is directly taken from hadley/lubridate, so you should try to make a request on this package. I have just rewritten it so that flooring to quarter is allowed.
Also note you can obtain the option end
by
floor_date(d, 'month') + months(1) - days(1)
Actually, two more things:
- ceiling_date in
lubridate
seems to do you want. - the newer version of lubridate incorporates flooring wrt quarter, so floor_date is going to disappear form statar.