Add JJ/MM/AAAA French date format

This commit is contained in:
khrys63 2023-07-24 20:37:50 +02:00 committed by Nick Hall
parent f59e4d2889
commit fa8cef2bf1

View File

@ -5,6 +5,7 @@
# #
# Copyright (C) 2004-2006 Donald N. Allingham # Copyright (C) 2004-2006 Donald N. Allingham
# Copyright (C) 2012 Mathieu MD # Copyright (C) 2012 Mathieu MD
# Copyright (C) 2023 Christophe aka khrys63
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@ -268,8 +269,9 @@ class DateDisplayFR(DateDisplay):
"Jour. Mois Année", # 4 "Jour. Mois Année", # 4
"Jour. MOI Année", # 5 "Jour. MOI Année", # 5
"Mois Jour, Année", # 6 "Mois Jour, Année", # 6
"MOI Jour, Année", "MOI Jour, Année", # 7
) # 7 "JJ/MM/AAAA", # 8
)
# this definition must agree with its "_display_gregorian" method # this definition must agree with its "_display_gregorian" method
def _display_gregorian(self, date_val, **kwargs): def _display_gregorian(self, date_val, **kwargs):
@ -387,6 +389,19 @@ class DateDisplayFR(DateDisplay):
date_val[0], date_val[0],
year, year,
) )
elif self.format == 8:
# French numerical with 0
if date_val[2] < 0 or date_val[3]:
return self.display_iso(date_val)
else:
if date_val[0] == date_val[1] == 0:
value = str(date_val[2])
else:
value = self.dhformat.replace('%m', str(date_val[1]).zfill(2))
value = value.replace('%d', str(date_val[0]).zfill(2))
value = value.replace('%Y', str(date_val[2]))
else: else:
return self.display_iso(date_val) return self.display_iso(date_val)