Fix French Republican 6th complementary day round-trip (equinox method)#62
Open
fbindakheel wants to merge 1 commit into
Open
Conversation
leap() short-circuited with 'if year < 15: return False' before running the equinox calculation. For the default equinox method this forced every year before 15 to be treated as non-leap, even though from_jd() (which is equinox-based) produces a 6th complementary day (sansculottide) for such leap years. As a result from_jd() could return (year, 13, 6) that to_jd() then rejected with 'Invalid day for this month', so the date failed to round-trip. Run the equinox leap calculation before the schematic 'year < 15' guard, which only describes the arithmetic methods (continuous/romme/madler). Behaviour of the schematic methods and historical years is unchanged. Add a regression test.
fitnr
reviewed
Jul 11, 2026
Comment on lines
+94
to
105
| if method == 'equinox': | ||
| # Determine astronomically whether the year has a 6th complementary | ||
| # day (i.e. 366 days). This must be checked before the `year < 15` | ||
| # short-circuit below, which only describes the schematic arithmetic | ||
| # methods. Otherwise from_jd() (which is equinox-based) can produce a | ||
| # 6th sansculottide for a year that to_jd()/leap() then reject, so the | ||
| # date fails to round-trip. | ||
| startjd = to_jd(year, 1, 1, method='equinox') | ||
| return premier_da_la_annee(startjd + 367) - startjd == 366.0 | ||
|
|
||
| if year < 15: | ||
| return False |
Owner
There was a problem hiding this comment.
This shortcircuit is obviously intentional. According to Wikipedia:
Thus, the years III, VII, and XI were observed as leap years, and the years XV and XX were also planned as such, even though they were five years apart.
That is unsourced, so more research is needed on the actual observation of leap years for the calendar before changing this logic
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
For the French Republican calendar (default
equinoxmethod),from_jd()can return a date thatto_jd()then rejects, so the date does not round-trip:This affects the 6th complementary day of equinox-method leap years before year 15 (e.g. proleptic years).
from_jd()produces the date;to_jd()/leap()refuse to accept it back.Root cause
to_jd()validates the 6th sansculottide withday > 5 + leap(year, method=method). Butleap()short-circuits with:before reaching the
equinoxbranch that actually computes year length astronomically. So for the default equinox method, every year < 15 (other than the hardcoded 3, 7, 11) is forced to non-leap — disagreeing withfrom_jd(), which is equinox-based. Theyear < 15guard is only meaningful for the schematic arithmetic methods (continuous/romme/madler).Fix
Run the equinox leap calculation before the
year < 15schematic guard. Schematic methods and historical years are unaffected.Tests
to_jd(4, 13, 6)still correctly raising — year 4 is genuinely not a leap year).test_french_republican_sixth_complementary_day_roundtrip, which round-trips the previously-failing dates and confirms historical sextile years (3, 7, 11) still work. Verified this test fails on the current code and passes with the fix.