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

Re: [MacPerl] 1900-2000 problem.



At 19:55 +0100 18.12.97, Anders Gardebring wrote:
>Just a small question.
>Is it possible to ask MacPerl to give 4 figures rather than two when Im asking
>for the year?
>Now Im doing like this:
>
> @date = localtime;
>        $date[5] +=1900; # Add 1900 to the year....
>
>This is of course not so good when we pass year 2000....
>Any help greatly appreciated :)

When we pass 1999 Perl will return a year with 3 digits, so you should
simply add 1900 to the year and always get the correct year.

But you can use localtime in a scalar context instead of an array context
and then you get a date line with a four digit year.

$s = localtime;
print $s, "\n";

WIll print something like "Thu Dec 18 20:29:30 1997" which you can split
and pop to get the four digit year.

Strange but totally Perl ;-)

	--jc

--
JŸrgen Christoffel, GMD - Forschungszentrum Informationstechnik GmbH
E-Mail: christoffel@gmd.de or one of {ftp,news,web}master@gmd.de



***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch