[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Y2k problem in perl 5.004.04-7

Rodrigo Fernandez-Vizarra Bonet wrote:
> Hi,
> I'm using Debian 2.1 with perl 5.004.04-7, I'm new to perl so I'm not
> sure if I'm doing something wrong (I don't think so). I've written this
> little script to get the actual date in the "day - month - year" format,
> I'm sure there are others ways but ...
> #!/usr/bin/perl
> use Time::localtime;
> $day = (localtime(time())->mday);
> $month = (localtime(time())->mon);
> $year = (localtime(time())->year);
> $date = "$day-$month-$year";
> printf("Actual date %s\n", $date);
> When I execute the script I obtain the following output
> $ ./test.pl
> Actual date 22-0-100
> $


perldoc -f localtime:

All array elements are numeric, and come straight out of a struct tm.
In particular this means that C<$mon> has the range C<0..11> and C<$wday>
has the range C<0..6> with sunday as day C<0>.  Also, C<$year> is the
number of years since 1900, that is, C<$year> is C<123> in year 2023,
and I<not> simply the last two digits of the year.  If you assume it is,
then you create non-Y2K-compliant programs--and you wouldn't want to do
that, would you?



A mathematician is a machine for converting coffee into theorems.

Reply to: