On 5:59 PM 3/4/01 John W Baxter <[EMAIL PROTECTED]> wrote:
> At 6:33 +0900 3/5/01, [EMAIL PROTECTED] wrote:
> >?One for the Perl gurus on the list- not a major problem but more of
> >a philosophical debate, while doing some date related work I noticed
> >that sprintf() & printf() didn't behave as I expected them to, the
> >following snippet:
> >
> >#!perl-w
> >
> >printf("%2d",((localtime(time))[5])),"¥n";
> >
> >yields '101' not '01' as I expected (which was: that this would
> >'round down' the number much in the way it 'rounds up' decimals), as
> >I was looking to build a short date (ending in '/01' rather than
> >'2001' ) I simply did:
> >
> Yes. Unix (and therefore Perl) appeared for many years to be
> returning the 2-digit year in that slot. Not so...they were (and
> are) returning the year - 1900.
This from the same person who just posted, in separate thread:
> At 2:03 AM +0900 3/3/01, [EMAIL PROTECTED] wrote:
>
> Of course you didn't because you don't have one and you didn't
> follow the 3 golden rules of posting-
> 1] Read the PODs
> 2] Read the PODs
> 3] Read the PODs
>From perlfunc.pod:
localtime EXPR
Converts a time as returned by the time function to a 9-element
array 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 array elements are numeric, and come straight out of a struct
tm. In particular this means that $mon has the range 0..11 and $wday
has the range 0..6 with sunday as day 0. Also, $year is the number
of years since 1900, that is, $year is 123 in year 2023.
If EXPR is omitted, uses the current time (localtime(time)).
In a scalar context, returns the ctime(3) value:
$now_string = localtime; # e.g., "Thu Oct 13 04:54:34 1994"
Also see the Time::Local module, and the strftime(3) and mktime(3)
function available via the POSIX module.
--
Jim Correia Bare Bones Software, Inc.
[EMAIL PROTECTED] <http://web.barebones.com>