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

leap_year() not working for a new class "yearmonth" #703

Closed
earowang opened this issue Aug 7, 2018 · 4 comments · Fixed by #820
Labels

Comments

@earowang
Copy link
Contributor

@earowang earowang commented Aug 7, 2018

There's a new class "yearmonth" from the tsibble package. Its underlying class is Date. year() works for it but leap_year() doesn't. This is due to recognize() is too strict using all(). Can we use any() instead? I'm happy to give a pull request too. Thanks.

library(lubridate)
#> 
#> Attaching package: 'lubridate'
#> The following object is masked from 'package:base':
#> 
#>     date
x <- tsibble::yearmonth(Sys.Date())
x
#> [1] "2018 Aug"
class(x)
#> [1] "yearmonth" "Date"
leap_year(x)
#> Error in leap_year(x): unrecognized date format
year(x)
#> [1] 2018

Created on 2018-08-07 by the reprex
package
(v0.2.0).

@hadley hadley added the bug label Nov 19, 2019
@hadley

This comment has been minimized.

Copy link
Member

@hadley hadley commented Nov 19, 2019

Are you still interested in doing a PR? I think the right approach would be to eliminate recognize() and instead make leap_year() a generic.

@earowang

This comment has been minimized.

Copy link
Contributor Author

@earowang earowang commented Nov 20, 2019

Yep, happy to do a PR.

A better approach would be to simplify the code and just rely on the year() (already S3 generic) internally?

year <- year(date)

earowang added a commit to earowang/lubridate that referenced this issue Nov 20, 2019
@hadley

This comment has been minimized.

Copy link
Member

@hadley hadley commented Nov 20, 2019

Oh yeah, totally 😅

@hadley hadley added the wip label Nov 20, 2019
@hadley hadley closed this in #820 Nov 20, 2019
hadley added a commit that referenced this issue Nov 20, 2019
Fixes #703
@vspinu

This comment has been minimized.

Copy link
Member

@vspinu vspinu commented Nov 28, 2019

Thanks @earowang!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.