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?
views:
141answers:
2
+2
A:
Hi metashockwave, see this link
http://stackoverflow.com/questions/453208/how-can-i-calculate-the-age-of-a-person-in-year-month-days
Bye.
RRUZ
2009-09-05 01:06:05
+1
A:
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
2009-09-05 01:12:39