[prev in list] [next in list] [prev in thread] [next in thread]
List: ruby-talk
Subject: Re: Calculating the age given DOB
From: Clifford Heath <no () spam ! please ! net>
Date: 2007-03-14 16:10:05
Message-ID: 45f81dea$0$16554$afc38c87 () news ! optusnet ! com ! au
[Download RAW message or body]
Brian Adkins wrote:
> (DateTime.now - birthdate) / 365.25
That's not very reliable. There are algorithms that calculate
the number of days since some epoch from a date, and the
reverse, based on Fortran code that was posted in the CACM
sometime around 1970. I have a copy somewhere, but there
must be a modern version already in Ruby. If you can't
find a way, I'll dig out mine.
Just convert both dates to days-since-epoch and subtract.
Clifford.
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic