From owner-freebsd-hackers Thu Nov 30 01:16:11 1995 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.6.12/8.6.6) id BAA10398 for hackers-outgoing; Thu, 30 Nov 1995 01:16:11 -0800 Received: from bunyip.cc.uq.oz.au (pp@bunyip.cc.uq.oz.au [130.102.2.1]) by freefall.freebsd.org (8.6.12/8.6.6) with SMTP id BAA10273 ; Thu, 30 Nov 1995 01:15:56 -0800 Received: from cc.uq.oz.au by bunyip.cc.uq.oz.au id <28670-0@bunyip.cc.uq.oz.au>; Thu, 30 Nov 1995 19:15:01 +1000 Received: from saturn.mincom.oz.au by minbne.mincom.oz.au with SMTP id AA27299 (5.65c/IDA-1.4.4 for jkh@freefall.freebsd.org); Thu, 30 Nov 1995 10:33:30 +1000 Received: by saturn.mincom.oz.au id AA15733 (5.65c/IDA-1.4.4 for hackers@freefall.freebsd.org); Thu, 30 Nov 1995 10:38:23 +1000 From: Ian Holland Message-Id: <199511300038.AA15733@saturn.mincom.oz.au> Subject: Re: Bug in stable/-current perl? To: jkh@freefall.freebsd.org (Jordan K. Hubbard) Date: Thu, 30 Nov 1995 10:38:23 +1000 (EST) Cc: hackers@freefall.freebsd.org In-Reply-To: <199511290543.VAA13120@freefall.freebsd.org> from "Jordan K. Hubbard" at Nov 28, 95 09:43:31 pm Reply-To: ianh@mincom.oz.au X-Mailer: ELM [version 2.4 PL21] Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Length: 875 Sender: owner-hackers@FreeBSD.ORG Precedence: bulk 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