develooper Front page | perl.perl5.porters | Postings from May 2012

[perl #24582] localtime returns gmtime instead of localtime

Thread Previous | Thread Next
From:
James E Keenan via RT
Date:
May 26, 2012 18:58
Subject:
[perl #24582] localtime returns gmtime instead of localtime
Message ID:
rt-3.6.HEAD-7788-1338083908-433.24582-15-0@perl.org
On Wed Dec 03 03:16:11 2003, arjen.bax@hetnet.nl wrote:
> A good day to you.
> 
> Michael G Schwern via RT wrote:
>  > On Tue, Dec 02, 2003 at 12:51:10PM -0000, arjen.bax@freeler.nl
>  > (via RT) wrote:
>  >
>  >>The following is NOT correct (does not take my timezone into account)
>  >
>  > Stupid question:  Is your timezone set?  In Cygwin?  Are you
>  > *sure*?  Is something stupid like daylight savings time still set?
> 
> According to my father, there are no stupid questions, only stupid
> answers. So here comes the answer... ;-)
> 
> My timezone is set in the windows control panel. This used to be
> sufficient with Perl v5.8.0, but it wasn't anymore after I installed
> v5.8.2. Mind that the only thing that I did between the two
> 
>      perl -wle 'print scalar localtime'
> 
> tests, was install the new Perl version. Before, localtime worked
> correctly; after, it didn't. I doublechecked by reinstalling the
> previous version. After that I filed the bug report.
> 
> I expected the new Perl version to be compatible with the old.
> 
> Before you ask: yes, I know how to set the TZ environment variable.
> I experimented a little with it. See the results below.
> 
> ========================================================================
> Beginning of test results with TZ variable
> ========================================================================
> 
> # the "real" local time: about 10 o'clock am; using Cygwin bash &c:
> $ date
> Wed Dec  3 10:07:25 WEST 2003
> # corresponds with my wrist watch
> $ perl -v
> This is perl, v5.8.2 built for cygwin-thread-multi-64int
> 
> # without TZ set:
> $ echo TZ=$TZ; perl -wle 'print scalar localtime'
> TZ=
> Wed Dec  3 09:09:55 2003
> # not correct; expecting 10 o'clock, not 09.
> 
> # set TZ explicitly (I live in the Netherlands, 1 hour east of Greenwich):
> $ TZ=WEST-1 perl -wle 'print scalar localtime'
> Wed Dec  3 09:10:39 2003
> # not correct; expecting 10 o'clock, not 09.
> 
> # simulate daylight savings time
> $ TZ=WEST-2 perl -wle 'print scalar localtime'
> Wed Dec  3 09:11:31 2003
> # not correct; expecting 11 o'clock, not 09.
> 
> # try west of Greenwich
> $ TZ=WEST+1 perl -wle 'print scalar localtime'
> Wed Dec  3 09:11:52 2003
> # not correct; expecting 08 o'clock, not 09.
> 
> # try one of the "old" USA time zones
> $ TZ=EST perl -wle 'print scalar localtime'
> Wed Dec  3 09:12:05 2003
> # not correct; expecting 04 o'clock, not 09.
> 
> ========================================================================
> Now reinstalling perl v5.8.0-5 and performing the same test. Nothing
> else changed on my PC.
> ========================================================================
> 
> $ date
> Wed Dec  3 10:21:41 WEST 2003
> # OK, time passes during testing, but still corresponds with my
> # watch ;-)
> 
> $ perl -v
> This is perl, v5.8.0 built for cygwin-multi-64int
> 
> # without TZ set:
> $ echo TZ=$TZ; perl -wle 'print scalar localtime'
> TZ=
> Wed Dec  3 10:21:51 2003
> # correct
> 
> # set TZ explicitly
> $ TZ=WEST-1 perl -wle 'print scalar localtime'
> Wed Dec  3 10:22:00 2003
> # correct
> 
> # simulate daylight savings time
> $ TZ=WEST-2 perl -wle 'print scalar localtime'
> Wed Dec  3 11:22:07 2003
> # correct
> 
> # try west of Greenwich
> $ TZ=WEST+1 perl -wle 'print scalar localtime'
> Wed Dec  3 08:22:15 2003
> # correct
> 
> # try one of the "old" USA time zones
> $ TZ=EST perl -wle 'print scalar localtime'
> Wed Dec  3 09:22:21 2003
> # not correct, but supposedly not supported
> 
> ========================================================================
> End of test
> ========================================================================
> 
> So it seems that (Cygwin) Perl v5.8.2 in my environment totally
> disregards the TZ setting, whereas Perl v5.8.0 correctly interprets it.
> 
> Thank you for your time looking into this problem.

Is there anyone currently building Cygwin Perl who could review the
issues raised in this older ticket?

Thank you very much.
Jim Keenan

---
via perlbug:  queue: perl5 status: open
https://rt.perl.org:443/rt3/Ticket/Display.html?id=24582

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About