Support final (sofit) Hebrew letters in gematriyaStrToNum - #24
Merged
Conversation
gematriyaStrToNum silently ignored the five final letters (ך ם ן ף ץ), which dropped the tens digit of any Hebrew year ending in 20, 40, 50, 80, or 90 — e.g. תש״ף parsed as 700 instead of 780, an 80-year error with nothing to signal it. This surfaced through HDate.fromGematriyaString, since תש״ף is how 5780 is actually written in human input even though gematriya() only ever emits the regular forms. Map the sofit letters to their base values when parsing. They are kept in a separate sofit2num table rather than added to heb2num so the num2heb reverse map (and thus gematriya() output) is unaffected. Fixes #22 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PdsgtSpAmYU8ChpqUo8fTH
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.
Problem
gematriyaStrToNumsilently ignored the five final (sofit) lettersך ם ן ף ץ, which dropped the tens digit of any Hebrew year ending in 20, 40, 50, 80, or 90:Since a Hebrew year's last letter falls in final form, every such year collapsed onto its bare century. This surfaced through
HDate.fromGematriyaString('א׳ שבט תש״ף'), which returned year 5700 instead of 5780 — an 80-year error with nothing to signal it. The round trip never caught it becausegematriya()only ever emits the regular forms, butתש״ףis how 5780 is actually written in human-authored input.Fixes #22.
Change
sofit2numtable rather than adding them toheb2num, becauseheb2numseeds thenum2hebreverse map used bygematriya(); adding sofit keys there would clobber entries likenum2heb[20]and corrupt emission. Parsing falls back withheb2num[ch] ?? sofit2num[ch], so number→string output is unaffected.HDate.fromGematriyaStringinherits the fix, since it delegates togematriyaStrToNum.Tests
gematriya.spec.ts: the six cases from the issue, plus a final/regular equivalence check (תש״ף===תש״פ).hdate.spec.ts: end-to-endHDate.fromGematriyaString('א׳ שבט תש״ף')→1 Sh'vat 5780.docExamplestest auto-verifies the new@example.Full suite passes,
tscand lint clean.🤖 Generated with Claude Code
https://claude.ai/code/session_01PdsgtSpAmYU8ChpqUo8fTH
Generated by Claude Code