Closed DavisVaughan closed 1 year ago
This looks great, I'm sold!
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: https://github.com/HowardHinnant/date/commit/323e2fa5fd7786e40014b02937a404ceb4c225d3
Yeah, I don't remember the details, but it likely got in there due to copy/paste from date::year
.
I tweaked the
iso_week.h
calendar to exposeyear::is_leap()
directly, and then reuse it when determiningyear_lastweek::weeknum()
. Would you be interested in having this upstream? It looks like the other calendars (likejulian.h
) have this function.Implemented here: https://github.com/r-lib/tzdb/pull/27
I used it here https://github.com/r-lib/clock/pull/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. Havingis_leap()
made it slightly more straightforward to implement.