Calculate an age

StephenRFerg at gmail.com StephenRFerg at gmail.com
Mon Dec 17 23:04:54 EST 2007


You might want to look at pyfdate: http://www.ferg.org/pyfdate

This Python program:
==============================================================================
from pyfdate import *
birthday = Time(2000,2,29)

today = Time(2003,2,28)
years, months, period = today.diffym(birthday)
print "On", today.d
print "person is", years, "years", months,"months", period.shortest

today = Time(2003,3,1)
years, months, period = today.diffym(birthday)
print "On", today.d
print "person is", years, "years", months,"months", period.shortest
==============================================================================

produces this output
==============================================================================
On February 28, 2003
person is 3 years 0 months
On March 1, 2003
person is 3 years 0 months 1 day
==============================================================================




More information about the Python-list mailing list