Brian Volk wrote:
Excellent summary of most methods at
http://perlmeme.org/faqs/datetime/comparing_dates.html.
Regards
James Turnbull
Hi All,
I'm running through the example of Date::Calc on the site listed above.
When I plug in today's date as my birthday... it returns:
I am -31 days old.
I would have guessed "0" days old. Can someone pls explain this to me?
(localtime)[5,4,3] stands for [$year, $mon, $mday] correct?
#!/usr/bin/perl
use strict;
use warnings;
use Date::Calc qw(Delta_Days);
my @today = (localtime)[5,4,3];
$today[0] += 1900;
my @birthday = (2006, 4, 6);
my $days = Delta_Days(@birthday, @today);
print "I am $days days old\n";
exit 0;
Thank you!>
perldoc -f localtime
localtime EXPR
Converts a time as returned by the time function
to a 9-element list with the time analyzed for the
local time zone. Typically used as follows:
# 0 1 2 3 4 5 6 7 8
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
localtime(time);
All list elements are numeric, and come straight
out of the C `struct tm'. $sec, $min, and $hour
are the seconds, minutes, and hours of the speci-
fied time. $mday is the day of the month, and
$mon is the month itself, in the range 0..11 with
0 indicating January and 11 indicating December.
$year is the number of years since 1900. That is,
$year is 123 in year 2023. $wday is the day of
the week, with 0 indicating Sunday and 3 indicat-
ing Wednesday. $yday is the day of the year, in
the range 0..364 (or 0..365 in leap years.)
$isdst is true if the specified time occurs during
daylight savings time, false otherwise.
Hope it helps.
--
Flemming Greve Skovengaard Man still has one belief,
a.k.a Greven, TuxPower One decree that stands alone
<[EMAIL PROTECTED]> The laying down of arms
4181.44 BogoMIPS Is like cancer to their bones
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>