in reply to Calculating a persons age based on their birthday.
As far as I understand, you would like to know the number of full years the person is alive?
So, assuming you have only the number of day, we can do the following:
---
my $year = (localtime)[5]+1900;
my $fullyears=0;
$nod = xxxx; #number of days goes here...
while ($nod > 365)
{ if ( $year % 4) {$nod=$nod-365} else {$nod=$nod-366}; #check for the leap year.
$year--; $fullyears++;
};
print "$fullyears\n";
---
Rather simple but m.b. not so gracefull solution :) You see, you do not need any special modules.
So, assuming you have only the number of day, we can do the following:
---
my $year = (localtime)[5]+1900;
my $fullyears=0;
$nod = xxxx; #number of days goes here...
while ($nod > 365)
{ if ( $year % 4) {$nod=$nod-365} else {$nod=$nod-366}; #check for the leap year.
$year--; $fullyears++;
};
print "$fullyears\n";
---
Rather simple but m.b. not so gracefull solution :) You see, you do not need any special modules.
|
---|
Replies are listed 'Best First'. | |
---|---|
RE: Re: Calculating a persons age based on their birthday.
by t0mas (Priest) on May 03, 2000 at 14:18 UTC | |
by t0mas (Priest) on May 03, 2000 at 14:43 UTC | |
by Maqs (Deacon) on May 03, 2000 at 15:15 UTC |
In Section
Seekers of Perl Wisdom