Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 30 Nov 1995 10:38:23 +1000 (EST)
From:      Ian Holland <ianh@tenmail.mincom.oz.au>
To:        jkh@freefall.freebsd.org (Jordan K. Hubbard)
Cc:        hackers@freefall.freebsd.org
Subject:   Re: Bug in stable/-current perl?
Message-ID:  <199511300038.AA15733@saturn.mincom.oz.au>
In-Reply-To: <199511290543.VAA13120@freefall.freebsd.org> from "Jordan K. Hubbard" at Nov 28, 95 09:43:31 pm

next in thread | previous in thread | raw e-mail | index | archive | help
As Jordan K. Hubbard enscribed:
> 
> jkh@freefall-> date
> Tue Nov 28 21:42:48 PST 1995
> 
> jkh@freefall-> perl -e 'printf("%02.2d\n", (localtime())[4]);'
> 10
> 
> 10?  Am I misunderstanding something fundamental about perl's
> localtime() call, or should this be an "11"?
> 

>From the man page (some deleted):

    localtime EXPR

	  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.
	  ^^^^^

[I admit this is from the perl 5 man page, but it was the same for
perl 4 - trust me ;-) ]

I think the rationale is that you can then easily use the month value as
an index into an array of real months names.  Ditto for the week day.

-- 
Ian Holland                      DOS - a case study in
Mincom Pty Ltd                   cerebral ischaemia.
ianh@mincom.oz.au



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199511300038.AA15733>