Lucky B skrev:
> how about surrounding the statement with a try and work the leap year
> to regular year case with the exception?
That seems like overkill. There isn't really any leap-year handling
necessary:

import datetime.date as date

def age (d1, d2=None):
    if not d2:
        d2 = date.today()
    years = d2.year - d1.year
    if (d2.month,d2.day) < (d1.month,d1.day):
        years -= 1
    return years

Nis

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to