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

floor_date(date, "year") is off by one in leap years #567

Closed
nacnudus opened this issue Jul 19, 2017 · 5 comments
Closed

floor_date(date, "year") is off by one in leap years #567

nacnudus opened this issue Jul 19, 2017 · 5 comments

Comments

@nacnudus
Copy link

@nacnudus nacnudus commented Jul 19, 2017

library(lubridate)
#> 
#> Attaching package: 'lubridate'
#> The following object is masked from 'package:base':
#> 
#>     date
floor_date(ymd("2016-02-29"), "year")
#> [1] "2016-01-01"
floor_date(ymd("2016-03-01"), "year")
#> [1] "2015-12-31"

# I would expect the equivalent of this
ymd("2016-02-29") - ddays(yday(ymd("2016-02-29")) - 1)
#> [1] "2016-01-01"
ymd("2016-03-31") - ddays(yday(ymd("2016-03-31")) - 1)
#> [1] "2016-01-01"
@hadley
Copy link
Member

@hadley hadley commented Aug 29, 2017

I just discovered this too

Loading

@DavisVaughan
Copy link
Member

@DavisVaughan DavisVaughan commented Sep 25, 2017

+1 to get this fixed. Was planning on using it for period conversion in tibbletime.

Loading

@vspinu
Copy link
Member

@vspinu vspinu commented Sep 26, 2017

Sorry for being slow on this and other issues. My bandwidth for R open source has been close to zero recently. Will have a look later this week.

Loading

@DavisVaughan
Copy link
Member

@DavisVaughan DavisVaughan commented Sep 27, 2017

@vspinu, I'm no expert on lubridate, but I forked it and commenting out this line seems to fix the problem. I'm not sure if that line needs to be there? Just a thought.

All tests (that were passing before the change) still pass.

Loading

@vspinu
Copy link
Member

@vspinu vspinu commented Oct 1, 2017

@DavisVaughan, you are right. I have no idea why that line is there.. It might have had some sense in the earlier drafts of that functionality, but I don't recall anymore.

Loading

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

Successfully merging a pull request may close this issue.

None yet
4 participants