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

perl 5.005_03 i686-linux-thread localtime() is not Y2K clean #848

Closed
p5pRT opened this issue Nov 12, 1999 · 5 comments
Closed

perl 5.005_03 i686-linux-thread localtime() is not Y2K clean #848

p5pRT opened this issue Nov 12, 1999 · 5 comments

Comments

@p5pRT
Copy link

p5pRT commented Nov 12, 1999

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

Searchable as RT1776$

@p5pRT
Copy link
Author

p5pRT commented Nov 12, 1999

From root@atrium.cardima.com

It appears that localtime() is not properly Y2K clean.

In a ticket submission tool​:

  $submitdate{$ticket} = time;

Later, in a ticket database browser​:

  $submitdate = $dblist{'submitdate'}->{$ticket};
  ($junk, $min, $hour, $mday, $junk, $year, $junk, $junk, $junk) = localtime($submitdate);
  $weekday = (Sun,Mon,Tue,Wed,Thu,Fri,Sat)[(localtime($submitdate))[6]];
  $month = (Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec)[(localtime($submitdate))[4]];
  $date = sprintf ("%02d​:%02d %s %s %d, %04d", $hour, $min, $weekday, $month, $mday, $year);

The resulting formatted date​: 17​:32 Fri Nov 12, 0099
Adding 5 years worth of seconds to the value passed to localtime() results
in a year of 0104.

Workaround​: Add 1900 to the year field.

Perl Info


Site configuration information for perl 5.00503:

Configured by root at Tue Oct 19 15:55:17 PDT 1999.

Summary of my perl5 (5.0 patchlevel 5 subversion 3) configuration:
  Platform:
    osname=linux, osvers=2.2.12, archname=i686-linux-thread
    uname='linux atrium 2.2.12 #4 thu sep 2 14:21:10 pdt 1999 i686 unknown '
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=define useperlio=undef d_sfio=undef
  Compiler:
    cc='cc', optimize='-O2', gccversion=2.95.1 19990816 (release)
    cppflags='-D_REENTRANT -Dbool=char -DHAS_BOOL -I/usr/local/include'
    ccflags ='-D_REENTRANT -Dbool=char -DHAS_BOOL -I/usr/local/include'
    stdchar='char', d_stdstdio=define, usevfork=false
    intsize=4, longsize=4, ptrsize=4, doublesize=8
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    alignbytes=4, usemymalloc=n, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /shlib /lib /usr/lib
    libs=-lnsl -lndbm -lgdbm -ldbm -ldb -ldl -lm -lpthread -lc -lposix
    libc=/lib/libc.so.5.4.46, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
    cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'

Locally applied patches:
    


@INC for perl 5.00503:
    /usr/lib/perl5/5.00503/i686-linux-thread
    /usr/lib/perl5/5.00503
    /usr/lib/perl5/site_perl/5.005/i686-linux-thread
    /usr/lib/perl5/site_perl/5.005
    .


Environment for perl 5.00503:
    HOME=/root
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH=/usr/local/lib
    LOGDIR (unset)
    PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin:/usr/local/sbin:/usr/X11R6/bin:/usr/bin/X11:/usr/openwin/bin:/usr/games:/scripts:/usr/lib/news/bin:/usr/local/majordomo:/usr/local/netscape:/usr/wp8/wpbin:/usr/local/DjVu:/usr/local/Acrobat4/bin:/usr/l

ocal/RedCreek:.
    PERL_BADLANG (unset)
    SHELL=/bin/bash

@p5pRT
Copy link
Author

p5pRT commented Nov 12, 1999

From [Unknown Contact. See original ticket]

Phil Stracchino <root@​atrium.cardima.com> writes​:

    $submitdate = $dblist\{'submitdate'\}\->\{$ticket\};
    \($junk\, $min\, $hour\, $mday\, $junk\, $year\, $junk\, $junk\, $junk\) = localtime\($submitdate\);
    $weekday = \(Sun\,Mon\,Tue\,Wed\,Thu\,Fri\,Sat\)\[\(localtime\($submitdate\)\)\[6\]\];
    $month = \(Jan\,Feb\,Mar\,Apr\,May\,Jun\,Jul\,Aug\,Sep\,Oct\,Nov\,Dec\)\[\(localtime\($submitdate\)\)\[4\]\];
    $date = sprintf \("%02d&#8203;:%02d %s %s %d\, %04d"\, $hour\, $min\, $weekday\, $month\, $mday\, $year\);

The resulting formatted date​: 17​:32 Fri Nov 12, 0099
Adding 5 years worth of seconds to the value passed to localtime() results
in a year of 0104.

Not a bug. Read​:

perldoc -f localtime

for details. You also might want to check strftime in the POSIX
package for more robust date printing.

Chip

--
Chip Turner chip@​ZFx.com
  Programmer, ZFx, Inc. www.zfx.com
  PGP key available at wwwkeys.us.pgp.net

@p5pRT
Copy link
Author

p5pRT commented Nov 12, 1999

From @tamias

On Fri, Nov 12, 1999 at 06​:15​:28PM -0800, Phil Stracchino wrote​:

It appears that localtime() is not properly Y2K clean.

Workaround​: Add 1900 to the year field.

It appears that you need to RTFM. Specifically the part of the FM for
localtime() where it tells you to add 1900 to the year value.

Ronald

@p5pRT
Copy link
Author

p5pRT commented Nov 16, 1999

From @mjdominus

On Fri, Nov 12, 1999 at 06​:15​:28PM -0800, Phil Stracchino wrote​:

It appears that localtime() is not properly Y2K clean.

Workaround​: Add 1900 to the year field.

I am going to count the bogus error reports submitted to P5P during
calendar year 2000. These will include​:

  `The month is off by one!'

  `The year is wrong!'

  `It has a y2k problem!'

  `It says that 2000 is a leap year, but century years are exempt!'

If you would like to try to guess how many of these reports are
submitted, and you have a PAUSE id, you can register your guess at

  http​://www.plover.com/~mjd/perl/y2k/y2k.cgi

I will announce the winner in January 2001.

Registration will close at the end of 1999.

@p5pRT
Copy link
Author

p5pRT commented Nov 16, 1999

From @RandalSchwartz

"Mark-Jason" == Mark-Jason Dominus <mjd@​plover.com> writes​:

Mark-Jason> I will announce the winner in January 2001.

Shouldn't that be 19101?

:-)

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@​stonehenge.com> <URL​:http​://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

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