Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , 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 To: cygwin AT cygwin DOT com Subject: Re: perl 5.8.2's localtime reports gmtime Message-ID: <20040308175243.GA3476@efn.org> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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/