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

Closed
hadley opened this Issue Jul 27, 2016 · 2 comments

Comments

Projects
None yet
3 participants
@hadley
Member

hadley commented Jul 27, 2016

i.e.

floor_date(now(), "2 weeks")

@vspinu vspinu closed this in 2cd8874 Aug 3, 2016

@vspinu vspinu reopened this Aug 3, 2016

@yeedle

This comment has been minimized.

Show comment
Hide comment
@yeedle

yeedle Aug 10, 2016

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

yeedle commented Aug 10, 2016

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

@vspinu vspinu closed this in c058038 Aug 16, 2016

@vspinu

This comment has been minimized.

Show comment
Hide comment
@vspinu

vspinu Aug 16, 2016

Member

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.

Member

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