@@ -547,25 +547,25 @@ def duration(self) -> Timedelta | UnDelta:
547547 # Date object allows optional month, but earliest/latest initialization
548548 # should always be day-precision dates
549549
550- # FIXME: earliest/latest are gregorian! need to use months from the original calendar,
551- # not converted months
550+ # use months from the original calendar, not months from
551+ # earliest/latest dates, which have been converted to Gregorian
552552 initial_month_value = self .initial_values ["month" ]
553553 # if integer, month is fully known and is the only possible value
554554 possible_months : list [int ] | range
555555 if isinstance (initial_month_value , int ):
556556 possible_months = [initial_month_value ]
557557 elif isinstance (initial_month_value , str ):
558- # earliest possible month for missing digit
559- earliest_month = int (
560- initial_month_value .replace (self .MISSING_DIGIT , "0" )
558+ # determine earliest and latest possible months
559+ # based on missing digits and calendar
560+ year = (
561+ self .year
562+ if isinstance (self .year , int )
563+ else self .calendar_converter .LEAP_YEAR
561564 )
562- # latest possible month for missing digit, but no greater than
563- # calendar max month
564- latest_month = min (
565- self .calendar_converter .max_month (
566- self .calendar_converter .LEAP_YEAR
567- ),
568- int (initial_month_value .replace (self .MISSING_DIGIT , "9" )),
565+ earliest_month , latest_month = self ._missing_digit_minmax (
566+ initial_month_value ,
567+ self .calendar_converter .min_month (),
568+ self .calendar_converter .max_month (year ),
569569 )
570570 possible_months = range (earliest_month , latest_month + 1 )
571571
0 commit comments