Date: Wed, 29 Nov 1995 08:25:29 +0500 From: Richard J Kuhns <rjk@sparcmill.grauel.com> To: "Jordan K. Hubbard" <jkh@freefall.freebsd.org> Cc: hackers@freefall.freebsd.org Subject: Bug in stable/-current perl? Message-ID: <9511291325.AA05867@sparcmill.grauel.com> In-Reply-To: <199511290543.VAA13120@freefall.freebsd.org> References: <199511290543.VAA13120@freefall.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
Jordan K. Hubbard writes:
> jkh@freefall-> date
> Tue Nov 28 21:42:48 PST 1995
>
> jkh@freefall-> perl -e 'printf("%02.2d\n", (localtime())[3]);'
> 28
> jkh@freefall-> perl -e 'printf("%02.2d\n", (localtime())[4]);'
> 10
> jkh@freefall-> perl -e 'printf("%02.2d\n", (localtime())[5]);'
> 95
>
> 10? Am I misunderstanding something fundamental about perl's
> localtime() call, or should this be an "11"?
>
> Jordan
>
>From `Programming Perl', page 157, referring to the return value of
localtime():
"All array elements are numeric, and come straight out of a struct
tm. [...] In particular this means that [the month value] has the range
0..11".
I think the idea is that you can use month value as a zero-based array
subscript to go from number to name. Day of week is done the same way.
--
Rich Kuhns rjk@grauel.com
PO Box 6249
100 Sawmill Road
Lafayette, IN 47903
(317)477-6000 x319
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?9511291325.AA05867>
