Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 29 Nov 1995 22:28:02 +0100 (MET)
From:      Ollivier Robert <roberto@keltia.freenix.fr>
To:        jkh@freefall.freebsd.org (Jordan K. Hubbard)
Cc:        hackers@freefall.freebsd.org
Subject:   Re: Bug in stable/-current perl?
Message-ID:  <199511292128.WAA03724@keltia.freenix.fr>
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
It seems that Jordan K. Hubbard said:
> 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"?

You're missing the fact that $mon (the  fifth parameter) is 0-based per the
man page:

               the local timezone.  Typically used as follows:

               ($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

So 10 == 11 :-)
-- 
Ollivier ROBERT    -=- The daemon is FREE! -=-    roberto@keltia.frmug.fr.net
   FreeBSD keltia.freenix.fr 2.2-CURRENT #7: Mon Nov  6 21:08:06 MET 1995



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