This commit is contained in:
2026-02-27 07:04:54 +01:00
parent e768fe71a3
commit 6b884af9cc
2 changed files with 21 additions and 3 deletions

View File

@@ -1,5 +1,5 @@
from decimal import Decimal, ROUND_HALF_UP
from datetime import date
UNITS = (
"ZERO ONE TWO THREE FOUR FIVE SIX SEVEN EIGHT NINE TEN ELEVEN TWELVE "
@@ -8,6 +8,19 @@ UNITS = (
TENS = "ZERO TEN TWENTY THIRTY FORTY FIFTY SIXTY SEVENTY EIGHTY NINETY".split()
def format_date_en(d):
if not d:
return ''
day = d.day
# Gestion des suffixes ordinaux
if 10 <= day % 100 <= 20:
suffix = 'TH'
else:
suffix = {1: 'ST', 2: 'ND', 3: 'RD'}.get(day % 10, 'TH')
return f"{day}{suffix} {d.strftime('%B').upper()} {d.year}"
def _under_thousand(n):
words = []