@@ -40,13 +40,12 @@ def is_leap_year(year : int) -> bool:
4040 return (year % 400 == 0 ) or (year % 4 == 0 and year % 100 != 0 )
4141
4242def days_in_month (* , month : int , is_leap_year : bool ) -> int :
43- match month :
44- case 1 | 3 | 5 | 7 | 8 | 10 | 12 : return 31
45- case 4 | 6 | 9 | 11 : return 30
46- case 2 :
47- return 29 if is_leap_year else 28
48- case _:
49- raise InvalidDate
43+ if month in [1 , 3 , 5 , 7 , 8 , 10 , 12 ]: return 31
44+ elif month in [4 , 6 , 9 , 11 ]: return 30
45+ elif month == 2 :
46+ return 29 if is_leap_year else 28
47+ else :
48+ raise InvalidDate
5049
5150def add_months_to_first_of_month_date (* , year : int , month : int , months : int ) -> tuple [int , int ]:
5251 """
@@ -139,10 +138,9 @@ def last_day_of_month(self) -> Date:
139138 def round (self , round : DateRounding ) -> Date :
140139 if self .is_valid : return self
141140 else :
142- match round :
143- case DateRounding .AbortOnRound : raise AmbiguousComputation
144- case DateRounding .RoundDown : return self .prev_valid_date ()
145- case DateRounding .RoundUp : return self .next_valid_date ()
141+ if round == DateRounding .AbortOnRound : raise AmbiguousComputation
142+ elif round == DateRounding .RoundDown : return self .prev_valid_date ()
143+ elif round == DateRounding .RoundUp : return self .next_valid_date ()
146144
147145 # This function is only ever called from `add_dates` below.
148146 # Hence, any call to `add_dates_years` will be followed by a call
0 commit comments