Fix for PERL Script (19100 date error)

greenspun.com : LUSENET : TimeBomb 2000 (Y2000) : One Thread

For those interested in WHY the year on debunkers (and others) WWWBOARDS show up as 19100, you should visit Matts Script Archives

following is from the Y2K FAQ page:

LINK

Y2K Fixes for MSA Scripts

There were a few small Y2K problems with some of the scripts at MSA> The biggest problem is that the date will appear incorrectly in the year 2,000, as 19,100 instead of 2,000. This was due to my misunderstanding of the localtime() command when I first begun programming over 5 years ago. The only programs this affects are Countdown, Counter, Free for all Links, TextClock, TextCounter and WWWBoard. The fixes are shown below. The rest of the scripts at MSA are believed to be fully Y2k compliant. You can either make the minor changes to your scripts that are already installed and working (which is easiest) or download the corrected versions.

WWWBoard

Lines 222 - 230 of wwwboard.pl should be changed from:
if ($use_time == 1) { $date = "$hour\:$min\:$sec $month/$mday/$year"; } else { $date = "$month/$mday/$year"; } chop($date) if ($date =~ /\n$/);
$long_date = "$months[$mon] $mday, 19$year at $hour\:$min\:$sec";

to:

$year += 1900; $long_date = sprintf("%s %02d, %4d at %02d:%02d:%02d",$months[$mon],$mday,$year,$hour,$min,$sec);
$year %= 100; if ($use_time == 1) { $date = sprintf("%02d:%02d:%02d %02d/%02d/%02d",$hour,$min,$sec,$month,$mday,$year); } else { $date = sprintf("%02d/%02d/%02d",$month,$mday,$year); }

Countdown

Line 65 in countdown.pl should be changed from:
$year ="19$year";

to:

$year += 1900;

Lines 120 - 132 (the subroutine leap_year_check) should be changed from:
sub leap_year_check { $yeardiv = ($year / 4); $yearint = int($yeardiv); $yeardiv1 = ($year / 100); $yearint1 = int($yeardiv1);
if ($yeardiv eq $yearint && $yeardiv1 ne $yearint1) { $feb_days = "28"; } else { $feb_days = "29"; } }

to:

sub leap_year_check { if ($year % 4 != 0 || ($year % 100 == 0 && $year % 400 != 0)) { $feb_days = "28"; } else { $feb_days = "29"; } }

Counter

Line 68 of counter.pl should be changed from:
$date = "$hour\:$min\:$sec $mon/$mday/$year";

to:

$year %= 100; $date = sprintf("%02d:%02d:%02d %02d/%02d/%02d",$hour,$min,$sec,$mon,$mday,$year);

In htmllog.pl the following line should be added after line 46, which is:
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); $mon++;

Line 57 should be changed from:
$date_now = "$hour\:$min\:$sec $mon/$mday/$year";

to:

$year %= 100; $date_now = sprintf("%02d:%02d:%02d %02d/%02d/%02d",$hour,$min,$sec,$mon,$mday,$year);

Free for all Links

Line 96 in links.pl should be changed from:
$date = "on $days[$wday], $months[$mon] $mday, 19$year at $hour:$min:$sec";

to:

$year += 1900; $date = "on $days[$wday], $months[$mon] $mday, $year at $hour:$min:$sec";

TextClock

Lines 80 - 88 of textclock.pl, which read:
Line 80 - 88:if ($Year > 95) { $Year = "19$Year"; } elsif ($Year < 10) { $Year = "200$Year"; } else { $Year = "20$Year"; }

should be replaced with the single line:

$Year += 1900;

TextCounter

Line 192 of counter.pl should be changed from:
$date = "@months[$mon] $mday, 19$year";

to:

$year += 1900; $date = "$months[$mon] $mday, $year";

-- plonk! (realaddress@hotmail.com), January 01, 2000

Answers

note the excuse given for the error(s):

" This was due to my misunderstanding of the localtime() command when I first begun programming over 5 years ago."

How many more programmers like this are out there?

D'OH!

-- plonk! (realaddress@hotmail.com), January 01, 2000.


I don't see a lot of troll stuff on this post. Could it be that the fact that this bug was right on the front of that site and that it was made by an inexperienced programmer be the reason? It seems that the pollies don't recognize this kind of bug as serious because they don'w view it as systemic....even though the curse of freeware is that it is ubiquitous and any errors like this will have to be fixed everywhere.

It looks like lots of people will need to update MSA type scripts. I guess this is an example of fix on failure, fortunately it is benign. I don't expect all will be and I certainly don't imagine that this is the only bug remaining.

-- William R. Sullivan (wrs@wham.com), January 01, 2000.


Moderation questions? read the FAQ