delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2004/03/08/12:53:04

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Date: Mon, 8 Mar 2004 09:52:44 -0800
From: Yitzchak Scott-Thoennes <sthoenna AT efn DOT org>
To: cygwin AT cygwin DOT com
Subject: Re: perl 5.8.2's localtime reports gmtime
Message-ID: <20040308175243.GA3476@efn.org>
References: <F67AB1DD14544242BE5BFE94F5939175B7F353 AT E2KMEMMCS1 DOT ftbco DOT ftn DOT com>
Mime-Version: 1.0
In-Reply-To: <F67AB1DD14544242BE5BFE94F5939175B7F353@E2KMEMMCS1.ftbco.ftn.com>
User-Agent: Mutt/1.4i
Organization: bs"d
X-IsSubscribed: yes

On Fri, Mar 05, 2004 at 10:53:12AM -0600, "DePriest, Jason R." wrote:
> I actually implemented the following so that my script will still work
> correctly after whatever whatever is fixed.
> 
> I am in the Central Time Zone, so you'd have to adjust the number of
> seconds you add or remove accordingly.
> 
> [code]
> use Time::Local;
> print "GM: " . gmtime() . "\n";
> print "Local: " . localtime() . "\n";
> if (gmtime() eq localtime()) {
> 	print "GM time and localtime are the same!\n";
> 	print "I'll have to make some adjustments.\n";
> 	if ($isdst) {
> 		$time = time() - 18000;
> 	} # end of if it is daylight savings time
> 	else {
> 		$time = time() - 21600;
> 	} # end of else it is standard time
> 	$adjtime = gmtime($time);
> 	print "Adjusted: $adjtime\n";
> 	($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
> gmtime($time);
> 	$mon += 1;
> 	$year += 1900;
> } # end of if local time is calculated as gm time
> else {	
> 	($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
> localtime;
> 	$mon += 1;
> 	$year += 1900;
> } # end of else the local time is correct
> [/code]

Just putting a:
use POSIX 'tzset'; tzset();
at the beginning of your script will work around the problem.

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019