hadley/lubridate — Issue #99: Fix ceiling_date for months
Author: garrettgman
Created: 2011-11-21 14:01:10+00:00
State: open

Dear Garrett Grolemund,

working with the R-package lubridate on monthly data I stumbled over something that I think isn't implemented quite right:

> ceiling_date(as.Date("2011-10-31"), "month")
[1] "2010-12-01"

This is not "the first day of the next month". Instead it is "the first of the second following month".

The problem occurs, because the operation

> month = month(x) <- month(x) + 1

doesn't return the 31st of november - because this date doesn't exist. Instead the 31.11. is handled like 01.12.

The whole thing doesn't occur if in ceiling_date() you first apply floor_date() and afterwards add a month.

I am greatly thankful for having the lubridate package! It's a pleasure to work with it, because it makes a lot much easier. So I want to use this occasion to thank you for the work you have done!

With kind regards,

Nanu Frechen