Commit 7a22644f authored by Marc Duez's avatar Marc Duez
Browse files

vidjil_utils : debug > birth_date can be missing

parent 1d6f4d59
......@@ -2,6 +2,7 @@ import math
import re
import defs
import json
import datetime
from gluon import current
from datetime import date
......@@ -50,7 +51,10 @@ def format_size(n, unit='B'):
def age_years_months(birth, months_below_year=4):
'''Get the age in years, and possibly months.'''
if not isinstance(birth, datetime.date) :
return '-/-'
today = date.today()
years = today.year - birth.year - ((today.month, today.day) < (birth.month, birth.day))
age = '%dy' % years
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment