Try:

print $age->deltas, "\n";

If the output from that doesn't look right to you please send it on to the list.

Code (DateTime is the current version available from CPAN):


#!/usr/bin/perl

use DateTime;

$birth=DateTime->new(year=>1968,month=>6,day=>28);
print $birth->ymd."\n";
$today=DateTime->today;
print $today->ymd."\n";
$age=$today-$birth;
print "Years:".$age->years."\n";
print "Months:".$age->months."\n";
print "Days:".$age->days."\n";
print "Deltas:".$age->deltas."\n";
print "Delta Months:".$age->delta_months."\n";
print "Delta Days:".$age->delta_days."\n";


Output:


1968-06-28
2003-08-17
Years:0
Months:0
Days:2
Deltas:10
Delta Months:0
Delta Days:12833

Again I fail to see the logic or even value in the DateTime::Duration behaving as above. But, I'm sure I'm probably just missing something important. The only one that does makes since is Deltas but only because it is returning a hash that has 10 elements in it. The Delta Days is sort of interesting but its seems like a lot of work for me to figure out the number of years from that especially when I think the point of this is to take into account all the strange ness that goes on between missing days seconds etc that go on over time.

Perhaps I'm just approaching this all wrong. I'm just looking for a simple way to compute some ones age today.

Reply via email to