mail: (strftime's encoding) patch plus propre

This commit is contained in:
Daniel STAN 2014-11-28 17:10:48 +01:00
parent 8928a950c7
commit be3f3507cc

View file

@ -35,11 +35,15 @@ templateLoader = jinja2.FileSystemLoader( searchpath=["/", template_path] )
templateEnv = jinja2.Environment( loader=templateLoader )
def format_date(d):
# Beware: l'encodage utilisé ici dépend de la locale choisie plus bas
if 'fr_FR' in locale.getlocale():
return d.strftime('%A %d %B %Y').decode('utf-8')
""" Renvoie une jolie représentation (unicode) d'un datetime"""
# L'encoding dépend de ce qu'on a choisi plus bas
lang, encoding = locale.getlocale()
if not encoding:
encoding = 'ascii'
if lang == 'fr_FR':
return d.strftime('%A %d %B %Y').decode(encoding)
else:
return d.strftime('%A, %B %d %Y').decode('utf-8')
return d.strftime('%A, %B %d %Y').decode(encoding)
def given_name(adh):
if 'club' in adh['objectClass']: