Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

localtime returns gmtime instead of localtime #6956

Closed
p5pRT opened this issue Dec 2, 2003 · 9 comments
Closed

localtime returns gmtime instead of localtime #6956

p5pRT opened this issue Dec 2, 2003 · 9 comments

Comments

@p5pRT
Copy link

p5pRT commented Dec 2, 2003

Migrated from rt.perl.org#24582 (status was 'resolved')

Searchable as RT24582$

@p5pRT
Copy link
Author

p5pRT commented Dec 2, 2003

From arjen.bax@freeler.nl

This is a bug report for perl from arjen.bax@​freeler.nl,
generated with the help of perlbug 1.34 running under perl v5.8.2.

The following is correct​:

Using Cygwin Perl from package perl-5.8.0-5.tar.bz2​:

$ perl -v

This is perl, v5.8.0 built for cygwin-multi-64int

[snip]

$ perl -wle 'print scalar localtime'
Tue Dec 2 13​:35​:10 2003

[now uninstall perl v5.8.0, install perl v5.8.2 using the cygwin
package manager; this takes approx 5 minutes]

The following is NOT correct (does not take my timezone into account)

Using Cygwin Perl from package perl-5.8.2-1.tar.bz2​:

$ perl -v

This is perl, v5.8.2 built for cygwin-thread-multi-64int

$ perl -wle 'print scalar localtime'
Tue Dec 2 12​:40​:16 2003

(This should be Tue Dec 2 13​:40​:16 2003).


Flags​:
  category=core
  severity=medium


Site configuration information for perl v5.8.2​:

Configured by Gerrit at Fri Nov 7 12​:03​:56 2003.

Summary of my perl5 (revision 5.0 version 8 subversion 2) configuration​:
  Platform​:
  osname=cygwin, osvers=1.5.5(0.9432), archname=cygwin-thread-multi-64int
  uname='cygwin_nt-5.0 troubardix 1.5.5(0.9432) 2003-09-20 16​:31 i686
unknown unknown cygwin '
  config_args='-de -Dmksymlinks -Duse64bitint -Dusethreads
-Doptimize=-O2 -Dman3ext=3pm'
  hint=recommended, useposix=true, d_sigaction=define
  usethreads=define use5005threads=undef useithreads=define
usemultiplicity=define
  useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
  use64bitint=define use64bitall=undef uselongdouble=undef
  usemymalloc=y, bincompat5005=undef
  Compiler​:
  cc='gcc', ccflags ='-DPERL_USE_SAFE_PUTENV -fno-strict-aliasing',
  optimize='-O2',
  cppflags='-DPERL_USE_SAFE_PUTENV -fno-strict-aliasing'
  ccversion='', gccversion='3.3.1 (cygming special)', gccosandvers=''
  intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=12345678
  d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
  ivtype='long long', ivsize=8, nvtype='double', nvsize=8,
Off_t='off_t', lseeksize=8
  alignbytes=8, prototype=define
  Linker and Libraries​:
  ld='ld2', ldflags =' -s -L/usr/local/lib'
  libpth=/usr/local/lib /usr/lib /lib
  libs=-lgdbm -ldb -lcrypt -lgdbm_compat
  perllibs=-lcrypt -lgdbm_compat
  libc=/usr/lib/libc.a, so=dll, useshrplib=true, libperl=libperl.a
  gnulibc_version=''
  Dynamic Linking​:
  dlsrc=dl_dlopen.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' -s'
  cccdlflags=' ', lddlflags=' -s -L/usr/local/lib'

Locally applied patches​:


@​INC for perl v5.8.2​:
  /usr/local/lib/perl5/site_perl/5.8.0
  /usr/local/lib
  /home/a.bax/perllib
  /usr/lib/perl5/5.8.2/cygwin-thread-multi-64int
  /usr/lib/perl5/5.8.2
  /usr/lib/perl5/site_perl/5.8.2/cygwin-thread-multi-64int
  /usr/lib/perl5/site_perl/5.8.2
  /usr/lib/perl5/site_perl
  .


Environment for perl v5.8.2​:
  HOME=/home/a.bax
  LANG (unset)
  LANGUAGE (unset)
  LD_LIBRARY_PATH (unset)
  LOGDIR (unset)

PATH=/usr/local/bin​:/usr/bin​:/bin​:/usr/X11R6/bin​:/d/abaxprog/texmf/miktex/bin​:/c/WINNT/system32​:/c/WINNT​:/c/WINNT/System32/Wbem​:/c/DMI/bin​:/c/Program
Files/Support Tools/​:/c/Program Files/Resource
Kit/​:/d/abaxprog/ATT/Graphviz/bin​:/d/abaxprog/ATT/Graphviz/bin/tools

PERL5LIB=/usr/local/lib/perl5/site_perl/5.8.0​:/usr/local/lib​:/home/a.bax/perllib
  PERL_BADLANG (unset)
  SHELL (unset)

--
Arjen Bax

Violence is the last refuge of the incompetent. - Isaac Asimov

@p5pRT
Copy link
Author

p5pRT commented Dec 3, 2003

From @schwern

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?

--
Michael G Schwern schwern@​pobox.com http​://www.pobox.com/~schwern/
Let me check my notes.
  http​://www.sluggy.com

@p5pRT
Copy link
Author

p5pRT commented Dec 3, 2003

From arjen.bax@hetnet.nl

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.

Greetings,

--
Arjen Bax

Violence is the last refuge of the incompetent. - Isaac Asimov

@p5pRT
Copy link
Author

p5pRT commented Dec 3, 2003

From @schwern

On Wed, Dec 03, 2003 at 10​:43​:41AM +0100, Arjen Bax wrote​:

Thank you for your time looking into this problem.

Thank you for answering my stupid question so thoroughly.

--
Michael G Schwern schwern@​pobox.com http​://www.pobox.com/~schwern/
AY! The ground beef, she is burning my groin!
  http​://sluggy.com/d/990105.html

@p5pRT
Copy link
Author

p5pRT commented Apr 10, 2004

From reden@cpan.org

Same issue occurs with ActivePerl *IF* the TZ enviornment variable is
set to something. If you don't set it, OS localtime is returned.

(This must be set before perl.exe starts, clearing it within the script
doesn't make a difference)

Robert

@p5pRT
Copy link
Author

p5pRT commented May 27, 2012

From @jkeenan

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

@p5pRT
Copy link
Author

p5pRT commented May 27, 2012

From @tonycoz

On Sat, May 26, 2012 at 06​:58​:29PM -0700, James E Keenan via RT wrote​:

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?

Building blead​:

tony@​phobos ~/dev/perl/git/perl
$ ./perl -Ilib -le 'print scalar localtime'
Sun May 27 12​:27​:07 2012

tony@​phobos ~/dev/perl/git/perl
$ TZ=WEST-1 ./perl -Ilib -le 'print scalar localtime'
Sun May 27 03​:27​:17 2012

tony@​phobos ~/dev/perl/git/perl
$ ./perl -Ilib -le 'print scalar gmtime'
Sun May 27 02​:27​:31 2012

tony@​phobos ~/dev/perl/git/perl
$ TZ=EST ./perl -Ilib -le 'print scalar localtime'
Sat May 26 21​:29​:06 2012

tony@​phobos ~/dev/perl/git/perl
$ ./perl -v

This is perl 5, version 17, subversion 0 (v5.17.0-17-gf0ccce9) built for cygwin-thread-multi-64int

Copyright 1987-2012, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl". If you have access to the
Internet, point your browser at http​://www.perl.org/, the Perl Home Page.

So if I understand the problems described, it's fixed.

Tony

@p5pRT
Copy link
Author

p5pRT commented Jun 19, 2013

From @jkeenan

On Sat May 26 19​:31​:38 2012, tonyc wrote​:

On Sat, May 26, 2012 at 06​:58​:29PM -0700, James E Keenan via RT wrote​:

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?

Building blead​:

tony@​phobos ~/dev/perl/git/perl
$ ./perl -Ilib -le 'print scalar localtime'
Sun May 27 12​:27​:07 2012

tony@​phobos ~/dev/perl/git/perl
$ TZ=WEST-1 ./perl -Ilib -le 'print scalar localtime'
Sun May 27 03​:27​:17 2012

tony@​phobos ~/dev/perl/git/perl
$ ./perl -Ilib -le 'print scalar gmtime'
Sun May 27 02​:27​:31 2012

tony@​phobos ~/dev/perl/git/perl
$ TZ=EST ./perl -Ilib -le 'print scalar localtime'
Sat May 26 21​:29​:06 2012

tony@​phobos ~/dev/perl/git/perl
$ ./perl -v

This is perl 5, version 17, subversion 0 (v5.17.0-17-gf0ccce9) built
for cygwin-thread-multi-64int

Copyright 1987-2012, Larry Wall

Perl may be copied only under the terms of either the Artistic License
or the
GNU General Public License, which may be found in the Perl 5 source
kit.

Complete documentation for Perl, including FAQ lists, should be found
on
this system using "man perl" or "perldoc perl". If you have access to
the
Internet, point your browser at http​://www.perl.org/, the Perl Home
Page.

So if I understand the problems described, it's fixed.

Tony

No one has disputed Tony's judgment in the year since the last post in
this RT. So I'm closing it now.

Thank you very much.
Jim Keenan

@p5pRT
Copy link
Author

p5pRT commented Jun 19, 2013

@jkeenan - Status changed from 'open' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant