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

gmtime()/localtime() do not use time() #9193

Closed
p5pRT opened this issue Jan 18, 2008 · 7 comments
Closed

gmtime()/localtime() do not use time() #9193

p5pRT opened this issue Jan 18, 2008 · 7 comments

Comments

@p5pRT
Copy link

p5pRT commented Jan 18, 2008

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

Searchable as RT49914$

@p5pRT
Copy link
Author

p5pRT commented Jan 18, 2008

From abe@ztreet.demon.nl

Created by abeltje@droopy.local

perlfunc for gmtime (and localtime) says​:
  If EXPR is omitted, "gmtime()" uses the current time ("gmtime(time)").

This suggests that Perl's time() is used in this case, but it isn't :(

#! /usr/bin/perl
use warnings;
use strict;

# from perldoc -f gmtime
# If EXPR is omitted, "gmtime()" uses the current time ("gmtime(time)").

BEGIN { # time() needs to be redefined first
  *CORE​::GLOBAL​::time = sub { 1204286400 }; # 29 Feb 2008 12​:00​:00 GMT
}

printf "[ empty] %s\n", scalar gmtime( );
printf "[ time()] %s\n", scalar gmtime( time );
printf "[CORE​::time()] %s\n", scalar gmtime( CORE​::time );

Perl Info

Flags:
    category=core
    severity=low

Site configuration information for perl 5.10.0:

Configured by abeltje at Tue Dec 18 23:55:32 CET 2007.

Summary of my perl5 (revision 5 version 10 subversion 0) configuration:
  Platform:
    osname=darwin, osvers=8.11.1, archname=darwin-thread-multi-2level
    uname='darwin droopy.local 8.11.1 darwin kernel version 8.11.1: wed oct
10 18:23:28 pdt 2007; root:xnu-792.25.20~1release_i386 i386 i386 '
    config_args='-des -Dprefix=/opt/perl/perl5100 -Duseithreads'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=define, usemultiplicity=define
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=undef, use64bitall=undef, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-fno-common -DPERL_DARWIN -no-cpp-precomp
-fno-strict-aliasing -pipe -I/usr/local/include -I/opt/local/include',
    optimize='-O3',
    cppflags='-no-cpp-precomp -fno-common -DPERL_DARWIN -no-cpp-precomp
-fno-strict-aliasing -pipe -I/usr/local/include -I/opt/local/include'
    ccversion='', gccversion='4.0.1 (Apple Computer, Inc. build 5367)',
gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='env MACOSX_DEPLOYMENT_TARGET=10.3 cc', ldflags =' -L/usr/local/lib
-L/opt/local/lib'
    libpth=/usr/local/lib /opt/local/lib /usr/lib
    libs=-ldbm -ldl -lm -lc
    perllibs=-ldl -lm -lc
    libc=/usr/lib/libc.dylib, so=dylib, useshrplib=false, libperl=libperl.a
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' '
    cccdlflags=' ', lddlflags=' -bundle -undefined dynamic_lookup
-L/usr/local/lib -L/opt/local/lib'

Locally applied patches:



@INC for perl 5.10.0:
    /opt/perl/perl5100/lib/5.10.0/darwin-thread-multi-2level
    /opt/perl/perl5100/lib/5.10.0
    /opt/perl/perl5100/lib/site_perl/5.10.0/darwin-thread-multi-2level
    /opt/perl/perl5100/lib/site_perl/5.10.0
    .


Environment for perl 5.10.0:
    DYLD_LIBRARY_PATH (unset)
    HOME=/Users/abeltje
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)

PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/X11R6/bin:/usr/local/bin:/opt/local/bin:/opt/local/sbin
    PERL_BADLANG (unset)
    SHELL=/bin/bash


@p5pRT
Copy link
Author

p5pRT commented Jan 28, 2008

From @rgs

On 18/01/2008, via RT Abe Timmerman <perlbug-followup@​perl.org> wrote​:

perlfunc for gmtime (and localtime) says​:
If EXPR is omitted, "gmtime()" uses the current time ("gmtime(time)").

This suggests that Perl's time() is used in this case, but it isn't :(

Documentation reworded as #33095, thanks.

@p5pRT
Copy link
Author

p5pRT commented Jan 28, 2008

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Jan 28, 2008

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

@p5pRT p5pRT closed this as completed Jan 28, 2008
@p5pRT
Copy link
Author

p5pRT commented Jan 28, 2008

From abe@ztreet.demon.nl

Rafael Garcia-Suarez wrote​:

On 18/01/2008, via RT Abe Timmerman <perlbug-followup@​perl.org> wrote​:

perlfunc for gmtime (and localtime) says​:
If EXPR is omitted, "gmtime()" uses the current time ("gmtime(time)").

This suggests that Perl's time() is used in this case, but it isn't :(

Documentation reworded as #33095, thanks.

Thank you for picking this up!

In the Perl documentation I expect "build-in" to mean "into perl". Hence I'm
not sure this patch clears up the fact that it is about the time(3) function
from the Standard C Library.

I didn't send a patch earlier as I am not sure how to word it. Is this better?

Inline Patch
--- pod/perlfunc.pod.orig       2008-01-28 23:02:42.000000000 +0100
+++ pod/perlfunc.pod    2008-01-28 23:16:18.000000000 +0100
@@ -2751,7 +2751,7 @@
 Time, false otherwise.

 If EXPR is omitted, C<localtime()> uses the current time (as returned
-by the C<time()> built-in).
+by L<time(3)>).

 In scalar context, C<localtime()> returns the ctime(3) value:



HTH + Good luck\,

Abe
--
If I knew :​:DProf enough to what is supposed to be in the SvIVX
I would knowingly nod my head here.
  -- Jarkko Hietaniemi on p5p @​ 2002-05-14

@p5pRT
Copy link
Author

p5pRT commented Jan 29, 2008

From @rgs

On 28/01/2008, Abe Timmerman <abe@​ztreet.demon.nl> wrote​:

Rafael Garcia-Suarez wrote​:

On 18/01/2008, via RT Abe Timmerman <perlbug-followup@​perl.org> wrote​:

perlfunc for gmtime (and localtime) says​:
If EXPR is omitted, "gmtime()" uses the current time ("gmtime(time)").

This suggests that Perl's time() is used in this case, but it isn't :(

Documentation reworded as #33095, thanks.

Thank you for picking this up!

In the Perl documentation I expect "build-in" to mean "into perl". Hence I'm
not sure this patch clears up the fact that it is about the time(3) function
from the Standard C Library.

I didn't send a patch earlier as I am not sure how to word it. Is this better?

--- pod/perlfunc.pod.orig 2008-01-28 23​:02​:42.000000000 +0100
+++ pod/perlfunc.pod 2008-01-28 23​:16​:18.000000000 +0100
@​@​ -2751,7 +2751,7 @​@​
Time, false otherwise.

If EXPR is omitted, C<localtime()> uses the current time (as returned
-by the C<time()> built-in).
+by L<time(3)>).

Yes, OK, why not. Thanks, applied!

@p5pRT
Copy link
Author

p5pRT commented Jan 29, 2008

From RGIERSIG@cpan.org

Why not just state the gotcha?

I think "uses the current time" is clear enough and the user most of the
time doesn't care where the time comes from. And for those who wonder it
should clearly say where it doesn't come from...

Inline Patch
--- pod/perlfunc.pod.orig       2008-01-28 23:02:42.000000000 +0100
+++ pod/perlfunc.pod    2008-01-28 23:16:18.000000000 +0100
@@ -2751,7 +2751,7 @@
  Time, false otherwise.

-If EXPR is omitted, C<localtime()> uses the current time (as returned
-by the C<time()> built-in).
+If EXPR is omitted, C<localtime()> uses the current time (but does not
+call the C<time()> built-in).

  In scalar context, C<localtime()> returns the ctime(3) value:



Abe Timmerman wrote: > Rafael Garcia\-Suarez wrote​: >> On 18/01/2008\, via RT Abe Timmerman \ wrote​: >>> perlfunc for gmtime \(and localtime\) says​: >>> If EXPR is omitted\, "gmtime\(\)" uses the current time \("gmtime\(time\)"\)\. >>> >>> This suggests that Perl's time\(\) is used in this case\, but it isn't :\( >> Documentation reworded as \#33095\, thanks\. > > Thank you for picking this up\! > > In the Perl documentation I expect "build\-in" to mean "into perl"\. Hence I'm > not sure this patch clears up the fact that it is about the time\(3\) function > from the Standard C Library\. > > I didn't send a patch earlier as I am not sure how to word it\. Is this better? > > > \-\-\- pod/perlfunc\.pod\.orig 2008\-01\-28 23​:02​:42\.000000000 \+0100 > \+\+\+ pod/perlfunc\.pod 2008\-01\-28 23​:16​:18\.000000000 \+0100 > @​@​ \-2751\,7 \+2751\,7 @​@​ > Time\, false otherwise\. > > If EXPR is omitted\, C\ uses the current time \(as returned > \-by the C\ built\-in\)\. > \+by L\\)\. > > In scalar context\, C\ returns the ctime\(3\) value​: > > > > HTH \+ > Good luck\, > > Abe

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