This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: perl 5.8.2's localtime reports gmtime


> -----Original Message-----
> From: cygwin-owner at cygwin dot com 
> [mailto: cygwin-owner at cygwin dot com] On Behalf Of Keith Bainbridge

> Sent: Thursday, March 04, 2004 6:35 PM
> To: The Cygwin Mailing List
> Subject: Re: perl 5.8.2's localtime reports gmtime
> 
> 
> Steve Kelem wrote:
> 
> > I'm running the latest cygwin, including perl 5.8.2:
> > % perl -version
> >
> > This is perl, v5.8.2 built for cygwin-thread-multi-64int
> 
> Ug.  Read the archives.  This has come up several times in the last
> couple of weeks, it's a known bug that will be fixed in the 
> next Cygwin
> DLL release.  See for example
> <http://marc.theaimsgroup.com/?l=cygwin&m=107668514008908>.  Your
> options are: Try a recent snapshot, use Perl <= 5.8.0, or wait for
> Cygwin 1.5.8.
> 
> Brian
> 
>

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]

-Jason


--
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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]