X-Git-Url: https://git.immae.eu/?p=perso%2FDenise%2Foms.git;a=blobdiff_plain;f=gestion_donnees.py;h=82491ca606b168a12606f4bc1423784e9c6f7e2f;hp=2ba945df04aed47c62d15bda6d4c6c33362b2825;hb=9cb3c31c54b868e0c3a335ef3a4b4cdc81e479fb;hpb=5679dfd03c9761283e3a36d6d09798aaa334e1e9 diff --git a/gestion_donnees.py b/gestion_donnees.py index 2ba945d..82491ca 100644 --- a/gestion_donnees.py +++ b/gestion_donnees.py @@ -51,9 +51,9 @@ def convertit_age_vers_texte(nombre): """ convertit un nombre de jours en un truc plus lisible en mois, années, jours et renvoie une chaîne sous la forme 3a2m1j par exemple""" annees = int(nombre / jours_dans_annee) - restant = nombre - int(annees*jours_dans_annee) + restant = nombre - round(annees*jours_dans_annee) mois = int(restant/jours_dans_mois) - jours= restant - int(mois*jours_dans_mois) + jours= nombre - round(mois*jours_dans_mois + annees*jours_dans_annee) chaine = "" if annees >0: @@ -97,7 +97,12 @@ def convertit_date_vers_python(chaine,liste_err): warning("La date : "+chaine+" est invalide !",liste_err) return "" else: - return datetime.date(int(liste[0]),int(liste[1]),int(liste[2])) + try: + date = datetime.date(int(liste[0]),int(liste[1]),int(liste[2])) + except: + date = "" + warning("Impossible de lire la date "+chaine) + return date def convertit_date_vers_texte(date): """ convertit une date python en format texte aaaa-mm-jj"""