From owner-freebsd-hackers Wed Nov 29 06:13:53 1995 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.6.12/8.6.6) id GAA17195 for hackers-outgoing; Wed, 29 Nov 1995 06:13:53 -0800 Received: from zibbi.mikom.csir.co.za (zibbi.mikom.csir.co.za [146.64.24.58]) by freefall.freebsd.org (8.6.12/8.6.6) with ESMTP id GAA17187 ; Wed, 29 Nov 1995 06:13:41 -0800 Received: (from rbezuide@localhost) by zibbi.mikom.csir.co.za (8.6.12/8.6.9) id QAA07363; Wed, 29 Nov 1995 16:12:50 +0200 From: R Bezuidenhout Message-Id: <199511291412.QAA07363@zibbi.mikom.csir.co.za> Subject: Re: Bug in stable/-current perl? To: jkh@freefall.freebsd.org (Jordan K. Hubbard) Date: Wed, 29 Nov 1995 16:12:50 +0200 (SAT) 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 X-Mailer: ELM [version 2.4 PL23] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Length: 1681 Sender: owner-hackers@FreeBSD.ORG Precedence: bulk > > 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 # # # ########################################################################