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

Any interest in iso_week::year::is_leap()? #784

Closed
DavisVaughan opened this issue Apr 21, 2023 · 3 comments · Fixed by #785
Closed

Any interest in iso_week::year::is_leap()? #784

DavisVaughan opened this issue Apr 21, 2023 · 3 comments · Fixed by #785

Comments

@DavisVaughan
Copy link
Contributor

DavisVaughan commented Apr 21, 2023

I tweaked the iso_week.h calendar to expose year::is_leap() directly, and then reuse it when determining year_lastweek::weeknum(). Would you be interested in having this upstream? It looks like the other calendars (like julian.h) have this function.

Implemented here:
r-lib/tzdb#27

I used it here r-lib/clock#333, where I have calendar_leap_year() which takes an arbitrary calendar and reports on whether or not the year is a leap year, if the calendar supports such a thing. Having is_leap() made it slightly more straightforward to implement.

@HowardHinnant
Copy link
Owner

This looks great, I'm sold!

@DavisVaughan
Copy link
Contributor Author

Ok great I'll do a PR

For historical purposes, I also found this old commit that removed an iso_week::year::is_leap() method, but that one looks to have been treating the iso year in the same way as a Gregorian year, so that wasn't right. Likely a copy paste error when making the iso calendar? Anyways, just recording the finding for future readers: 323e2fa

@HowardHinnant
Copy link
Owner

Yeah, I don't remember the details, but it likely got in there due to copy/paste from date::year.

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

Successfully merging a pull request may close this issue.

2 participants