Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 29 Nov 1995 16:12:50 +0200 (SAT)
From:      R Bezuidenhout <rbezuide@mikom.csir.co.za>
To:        jkh@freefall.freebsd.org (Jordan K. Hubbard)
Cc:        hackers@freefall.freebsd.org
Subject:   Re: Bug in stable/-current perl?
Message-ID:  <199511291412.QAA07363@zibbi.mikom.csir.co.za>
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
> 
> 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


In perl localtime is used in the following format:

($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdat) =
          localtime(time);

but I guess you know that :)

What you missed is that both $mon and $wday is zero based.

So ...

$mon = 0..11
$wday = 0..6

The reason for this is that $mon and $wday is used as subscripts
into 0-based arrays containing month and day names.

Isn't this the same as with   "struct tm"   in C ? :) 
(This you you know too, I am sure :) )

So, if perl -e 'printf("%02.2d\n", (localtime())[4]);' that returns
a 10 in November is a feature ... not a bug :)

Regards 

-- 
########################################################################
#                                                                      #
#   Reinier Bezuidenhout             Company: Mikomtek CSIR, ZA        #
#                                                                      #
#   Network Engineer - NetSec development team                         #
#                                                                      #
#   Current Projects: NetSec - Secure Platform firewall system         #
#                     http://www.mikom.csir.co.za                      #
#                                                                      #
#   E-mail: rbezuide@mikom.csir.co.za                                  #
#                                                                      #
########################################################################



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