Bug 18879 - Y2K bug in perl
Summary: Y2K bug in perl
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: perl
Version: 6.2
Hardware: i386
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Crutcher Dunnavant
QA Contact: David Lawrence
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2000-10-11 10:22 UTC by braun
Modified: 2007-04-18 16:29 UTC (History)
0 users

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2000-10-11 10:35:43 UTC
Embargoed:


Attachments (Terms of Use)

Description braun 2000-10-11 10:22:30 UTC
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 10:35:38 UTC
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 14:40:22 UTC
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.