Expand Adar month name recognition with dedicated resolver - #25
Merged
Conversation
The Adar ordinal was decided from the last character of the string via
`/(1|[^i]i|a|א)$/`, which silently inverted several spelled-out forms:
`Adar Sheini` ended in `ni` and matched `[^i]i$`, resolving to Adar I,
while `אדר ראשון` / `Adar Rishon` / `Adar Alef` fell through to the Adar II
default — landing a yahrzeit or anniversary on the wrong, adjacent month.
Replace the trailing-character test with `adarFromName`, which inspects the
ordinal after the `adar`/`אדר` stem (ignoring separators and gershayim) and
matches the ordinal explicitly: `1`/`i`/`a`/`alef`/`aleph`/`rishon`/`א`/
`ראשון`/`אלף` resolve to Adar I; the explicit second-Adar spellings and any
unrecognized or missing suffix ("Adar", "Adar Bogus") deliberately default
to Adar II, matching the convention that an unqualified Adar means the
second Adar in a leap year.
Also expand the monthFromName docs to cover nikud stripping, the leading
bet prefix, and the Adar II default for ambiguous names, and add
table-driven test coverage across the spellings.
Fixes #23
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01954cvSHc23Ats2gn7GwuYG
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.
Summary
Refactored and expanded the Adar month name resolution logic to support a comprehensive set of transliterated and Hebrew spellings for both Adar I and Adar II, with improved documentation and test coverage.
Key Changes
adarFromName()function: Created a dedicated helper function that encapsulates all logic for resolving "Adar I vs Adar II" ambiguity from month name suffixes, replacing inline regex matching'Alef'/'Aleph'/'Alaph','Rishon'(and variants), and Hebrew equivalents'אלף'and'ראשון'(with prefix matching for flexibility)'Bet'/'Beit'/'Beis','Sheni'/'Sheini', and Hebrew equivalents'ב'and'שני'׳״) when extracting the ordinal suffix, allowing formats like'Adar-I','AdarI', and'אדר א׳'to be treated equivalently'Adar'defaults to Adar II'Adar Bogus'to verify the ambiguous-default behaviorImplementation Details
adarFromName()function normalizes the suffix by removing the'adar'/'אדר'stem and stripping separators/gershayim, then checks against recognized patterns for Adar I'Adar') deliberately default to Adar II, following the Hebrew calendar convention that an unqualified Adar refers to the second Adar in a leap yearhttps://claude.ai/code/session_01954cvSHc23Ats2gn7GwuYG