Bruno Desthuilliers wrote:
[...]
> Possible solution:
>
> import mx.DateTime as dt
> def age(date):
>     return dt.Age(dt.today(), date).years
> born = dt.Date(1967, 5, 1)
> assert age(born) == 39

dealbreaker:

>>> age(datetime.date(1970,5,2))
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "c:\python24\lib\site-packages\mx\DateTime\DateTime.py", line
842, in RelativeDateTimeDiff
    diff = date1 - date2
TypeError: unsupported operand type(s) for -: 'DateTime' and
'datetime.date'

I'm getting data from a database, and conversions are out of the
question for something like this. Otherwise it's a fine library :-)

-- bjorn

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to