Skip to content

Commit

Permalink
Merge the suggestions for DateTimeFormat.format_year
Browse files Browse the repository at this point in the history
  • Loading branch information
jun66j5 committed Jan 30, 2025
1 parent b0175f4 commit d5f31af
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions babel/dates.py
Original file line number Diff line number Diff line change
Expand Up @@ -1483,12 +1483,10 @@ def format_year(self, char: str, num: int) -> str:
value = self.value.year
if char.isupper():
month = self.value.month
if month == 1:
if self.value.day < 7 and self.get_week_of_year() >= 52:
value -= 1
elif month == 12:
if self.value.day > 25 and self.get_week_of_year() <= 2:
value += 1
if month == 1 and self.value.day < 7 and self.get_week_of_year() >= 52:
value -= 1
elif month == 12 and self.value.day > 25 and self.get_week_of_year() <= 2:
value += 1
year = self.format(value, num)
if num == 2:
year = year[-2:]
Expand Down

0 comments on commit d5f31af

Please sign in to comment.