feat(normalizer): year expansion century rule
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -39,6 +39,25 @@ def resolve_feast_or_season(token: str, year: int):
|
||||
return None
|
||||
|
||||
|
||||
def expand_year(token: str):
|
||||
"""Expand a 2/3/4-digit year string per the 1873–1957 century rule. None if ambiguous."""
|
||||
token = token.strip()
|
||||
if not token.isdigit():
|
||||
return None
|
||||
n, v = len(token), int(token)
|
||||
if n == 4:
|
||||
return v
|
||||
if n == 3:
|
||||
return 1000 + v
|
||||
if n == 2:
|
||||
if v <= config.TWO_DIGIT_19XX_MAX:
|
||||
return 1900 + v
|
||||
if v >= config.TWO_DIGIT_18XX_MIN:
|
||||
return 1800 + v
|
||||
return None
|
||||
return None
|
||||
|
||||
|
||||
def easter(year: int) -> datetime.date:
|
||||
"""Easter Sunday (Gregorian) via the Anonymous Gregorian / Butcher algorithm."""
|
||||
a = year % 19
|
||||
|
||||
Reference in New Issue
Block a user