Skip to content

Add Date.get_gregorian_ymd() and fix death anniversary calendar bug#2459

Open
dsblank wants to merge 1 commit into
gramps-project:masterfrom
dsblank:fix/gregorian-mdy-anniversary
Open

Add Date.get_gregorian_ymd() and fix death anniversary calendar bug#2459
dsblank wants to merge 1 commit into
gramps-project:masterfrom
dsblank:fix/gregorian-mdy-anniversary

Conversation

@dsblank

@dsblank dsblank commented Jul 5, 2026

Copy link
Copy Markdown
Member

Original issue found by @javadr on gramps-project/addons-source#974

Summary

  • Date.get_month()/get_day() return raw values in whatever calendar the date was recorded in. Code that extracts month/day from an event date and mixes it with Gregorian year arithmetic silently misplaces non-Gregorian dates (e.g. a Persian or Hebrew death date landing on the wrong Gregorian day).
  • In webreport/calendar.py and webreport/webcal.py, the birthday-anniversary code already guarded against this by converting to Gregorian before extracting month/day, but the neighboring death-anniversary code did not — same bug class as a recently-fixed 16-year-old bug in the BirthdaysGramplet addon (proximity sort using raw, non-Gregorian month/day).
  • Adds Date.get_gregorian_ymd(), returning (year, month, day) already converted to Gregorian, so future code has one obvious call instead of a two-step convert-then-extract pattern that's easy to forget.
  • Fixes the death anniversary calculation in both files to use the new method.

Test plan

  • Added GregorianYmdTest in gramps/gen/lib/test/date_test.py covering an already-Gregorian date (identity) and conversions from Persian, Julian, Hebrew, and Islamic calendars.
  • Added a doctest on get_gregorian_ymd() reproducing the Persian-new-year scenario from the original bug.
  • python3 -m unittest gramps.gen.lib.test.date_test — 45 passed.
  • black --check and mypy clean on changed files.

🤖 Generated with Claude Code

Date.get_month() and get_day() return raw values in whatever calendar
the date was recorded in, so code that pulls month/day from an event
date and mixes it with Gregorian year math silently misplaces
non-Gregorian dates (e.g. a Persian or Hebrew death date landing on the
wrong Gregorian day). The birthday code in NarrativeWeb's calendar
already guarded against this by converting to Gregorian first, but the
neighboring death anniversary code did not.

Add Date.get_gregorian_ymd(), a small wrapper that returns (year,
month, day) already converted to the Gregorian calendar, so callers
have one obvious method to reach for instead of a two-step
convert-then-extract pattern that is easy to forget. Use it to fix the
death anniversary calculation in both webreport/calendar.py and
webreport/webcal.py.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant