Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support units in floor_date() etc #442

hadley opened this issue Jul 27, 2016 · 2 comments

Support units in floor_date() etc #442

hadley opened this issue Jul 27, 2016 · 2 comments


Copy link

hadley commented Jul 27, 2016


floor_date(now(), "2 weeks")
@vspinu vspinu closed this as completed in 2cd8874 Aug 3, 2016
@vspinu vspinu reopened this Aug 3, 2016
vspinu added a commit that referenced this issue Aug 3, 2016
Copy link

yeedle commented Aug 10, 2016

was looking for similar functionality for rounding dates, e.g. round_date(x, "5 minutes")

@vspinu vspinu closed this as completed in c058038 Aug 16, 2016
Copy link

vspinu commented Aug 16, 2016

I have implemented this and added quite some tests, but would really appreciate if you guys could play with it a bit and run your own checks on corner cases.

Multiple of all units excepts weeks are supported (updating on weeks is not supported by POSIXlt) . Rounding on units that don't have a meaningful 0 (days and months) happens incrementally from 1:

> floor_date(ymd("2016-08-02"), "2 days")
[1] "2016-08-01"
> floor_date(ymd("2016-08-03"), "2 days")
[1] "2016-08-03"

This is consistent with how currently bimonthly, quarter and halfyear behave.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

No branches or pull requests

3 participants