0

Possible Duplicate:
How can I calculate the age of a person in year, month, days?

How to calculate the number of days that person has been alive on his Nth birthday? given his birth month, day, year, and his age? How to solve the leap year challenge?

Community
  • 1
  • 1
user133466
  • 3,391
  • 18
  • 63
  • 92
  • See also metashockwave's other related question: http://stackoverflow.com/questions/1381832/ – Jonathan Leffler Sep 05 '09 at 01:51
  • see this link [http://stackoverflow.com/questions/453208/how-can-i-calculate-the-age-of-a-person-in-year-month-days](http://stackoverflow.com/questions/453208/how-can-i-calculate-the-age-of-a-person-in-year-month-days) Bye. – RRUZ Sep 05 '09 at 01:06

1 Answers1

1

Here's a (sort of a) one-liner in Perl:

$ perl -MPOSIX -e '($d, $m, $y, $a) = @ARGV; print ((mktime(0,0,0,$d,$m+1,$y+$a-1900) - mktime(0,0,0,$d,$m+1,$y-1900)) / 86400)' 23 4 1975 29
10593

Of course, this passes off the key leap year calculations to the POSIX::mktime function.

Greg Hewgill
  • 951,095
  • 183
  • 1,149
  • 1,285