Bug 18879 - Y2K bug in perl
Y2K bug in perl
Status: CLOSED NOTABUG
Product: Red Hat Linux
Classification: Retired
Component: perl (Show other bugs)
6.2
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Crutcher Dunnavant
David Lawrence
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2000-10-11 06:22 EDT by braun
Modified: 2007-04-18 12:29 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2000-10-11 06:35:43 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description braun 2000-10-11 06:22:30 EDT
There is a problem with the array returned by gmtime in perl (RedHat 6.2 +
latest perl).
The following example prints year 100:

Script started on Wed Oct 11 12:07:24 2000
[braun@bastheth braun]$ cat ptime.pl
#!/usr/bin/perl

( $sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst ) = gmtime (time());

printf (" Current date is %2d/%2d/%4d .\n",$mon + 1, $mday, $year); 
[braun@bastheth braun]$ ./ptime.pl ; date
 Current date is 10/11/ 100 .
Wed Oct 11 12:07:45 MEST 2000
[braun@bastheth braun]$ rpm -q perl
perl-5.00503-12
[braun@bastheth braun]$ exit

Script done on Wed Oct 11 12:08:09 2000
Comment 1 braun 2000-10-11 06:35:38 EDT
Ok, it could be that $year is the number of years since 1900 (i. e. not a bug).
I found similar code in mirror-2.9 (dateconv.pl). Mirror actually sends mails
with year 100 in its body.

Mirrored rh70updates (ftp.gmd.de:/mirrors/redhat.com/updates/7.0 ->
/home/ftp/pub/linux/RedHat/updates/7.0) RedHat Linux Updates @ 11 Oct 100 10:35
Got SRPMS/usermode-1.36-3.src.rpm 59209 1
Comment 2 Crutcher Dunnavant 2000-10-11 10:40:22 EDT
Not a bug, perl documents this behaviour,

from 'perldoc -f gmtime':
  Note that the $year element is not simply the last
  two digits of the year.  If you assume it is, then
  you create non-Y2K-compliant programs--and you
  wouldn't want to do that, would you?

  The proper way to get a complete 4-digit year is
  simply:

  year += 1900;

Note You need to log in before you can comment on or make changes to this bug.