Calculate an age

thebjorn BjornSteinarFjeldPettersen at gmail.com
Thu Dec 6 19:07:26 EST 2007


On Dec 6, 11:19 pm, John Machin <sjmac... at lexicon.net> wrote:
> On Dec 7, 8:34 am, Pierre Quentel <quentel.pie... at wanadoo.fr> wrote:
>
> > Hi all,
>
> > I have searched in the standard distribution if there was a function
> > to return the difference between 2 dates expressed like an age :
> > number of years, of months and days. The difference between datetime
> > instances returns a timedelta object that gives a number of days, but
> > not an age
>
> > So is there such a function somewhere ? If not, for what reason, since
> > it's a rather usual task
>
> and a rather usually imprecisely specified task [what do you mean by
> "number of months"?] with multiple interpretations/implementations/
> doctrines the publication of any one of which attracts a truckload of
> rotten tomatoes and derision from adherents of other sects :-)

It may be imprecisely specified, yet it's quite useful anyway. I've
got an implementation at http://blog.tkbe.org/archive/python-how-old-are-you/
if anyone's interested..

-- bjorn



More information about the Python-list mailing list