MSA - Matt's Script Archive
 Matt's Script Archive: Frequently Asked Questions: Y2K FixesView All FAQs @ MSA
 
  Other sites by Matt:
 FormMail.com
  - hosted form processor


  Matt's Script Archive
    FormMail
    Guestbook
    WWWBoard
    Simple Search
    Counter
    TextCounter
    Random Text
    TextClock
    Free for all Links
    Random Link
    HTTP Cookie Library
    Countdown
    Random Image
    SSI Random Image
    TextCounter C++
    TextClock C++

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 (Download)
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);
}


Mark Mansfield submitted this change if you are using WWWBoard as modified by DBasics, you will also need to modify another line. This does not appear in the standard distribution. You must change the line that looks like:

if (length($dd) ==1) { $dd="0$dd"; }

to:

if (length($dd) ==1) { $dd="0$dd"; }
$yy %= 100;
Countdown (Download)
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 (Download)
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 (Download)
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 (Download)
Lines 80 - 88 of textclock.pl, which read:

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 (Download)
Line 192 of counter.pl should be changed from:

$date = "@months[$mon] $mday, 19$year";

to:

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

 

FormMail.com :: HTML Form to Email Processor
[ Linking to MSA | Advertising Opportunities | Contact Matt ]
© 1995 - 2009 Matt Wright and Matt's Script Archive, Inc.