Re: Date objects

Jack Jansen (Jack.Jansen@cwi.nl)
Tue, 17 Aug 1993 11:33:40 +0200

Wonderful! This means that an unbirthday program in python is now only
a couple of lines:

import Date
import sys

print 'Enter your day of birth as (day, month, year) - '
d, m, y = eval(sys.stdin.readline())
birth = Date.Date(m, d, y)
today = Date.today()
this_years_birthday = Date.Date(m, d, today.year)
if this_years_birthday == today:
print 'It is your', `today.year-y`+'th birthday today! Congratulations!'
else:
unbirthday = (today-birth)-(today.year-y)
if this_years_birthday > today:
unbirthday = unbirthday + 1
print 'Today is your', `int(unbirthday)`+'th unbirthday today! Congratulations!'

--
Jack Jansen        | If I can't dance I don't want to be part of
Jack.Jansen@cwi.nl | your revolution             -- Emma Goldman
uunet!cwi.nl!jack    G=Jack;S=Jansen;O=cwi;PRMD=surf;ADMD=400net;C=nl