diff: fix Y2K problems in CVSROOT/*.pl

Fergus Henderson fjh at cs.mu.OZ.AU
Sat Feb 20 09:25:54 AEDT 1999


CVSROOT/log.pl:
	Fix a Y2K problem.

CVSROOT/check.pl:
	Fix a Y2097 problem.  That is, replace my previous work-around
	of using a 100-year window 1997-2096 with a proper fix.

Index: CVSROOT/check.pl
===================================================================
RCS file: /home/mercury1/repository/CVSROOT/check.pl,v
retrieving revision 1.8
diff -u -r1.8 check.pl
--- check.pl	1998/06/19 00:14:15	1.8
+++ check.pl	1999/02/19 21:12:48
@@ -13,16 +13,9 @@
 # we want them to have a copyright message that specifies the current year
 
 ($_sec,$_min,$_hour,$_mday,$_mon,$year,$_wday,$_yday,$_isdst) = localtime;
-if ($year < 100) {
-	# sheesh, how come the year doesn't include a century?
-	if ($year < 97) {
-		# assume 21st century
-		$year = 2000 + $year;
-	} else {
-		# assume 20th century
-		$year = 1900 + $year;
-	}
-}
+# localtime returns years since 1900, so we need to add 1900
+# to convert to years AD
+$year += 1900;	
 
 #-----------------------------------------------------------------------------#
 
Index: CVSROOT/log.pl
===================================================================
RCS file: /home/mercury1/repository/CVSROOT/log.pl,v
retrieving revision 1.9
diff -u -r1.9 log.pl
--- log.pl	1998/08/05 02:50:19	1.9
+++ log.pl	1999/02/19 21:13:50
@@ -74,6 +74,9 @@
 @days = (Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday);
 
 ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime;
+# localtime returns years since 1900, so we need to add 1900
+# to convert to years AD
+$year += 1900;
 
 # get login name
 #
@@ -91,12 +94,12 @@
 # 
 print OUT "\n";
 print OUT "**************************************\n";
-print OUT "Date:\t$days[$wday] $mos[$mon] $mday, 19$year @ $hour:" . sprintf("%02d", $min) . "\n";
+print OUT "Date:\t$days[$wday] $mos[$mon] $mday, $year @ $hour:" . sprintf("%02d", $min) . "\n";
 print OUT "Author:\t$login\n\n";
 
 if (MAIL) {
 	print MAIL "\n";
-	print MAIL "Date:\t$days[$wday] $mos[$mon] $mday, 19$year @ $hour:" . sprintf("%02d", $min) . "\n";
+	print MAIL "Date:\t$days[$wday] $mos[$mon] $mday, $year @ $hour:" . sprintf("%02d", $min) . "\n";
 	print MAIL "Author:\t$login\n\n";
 }
 

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "Binaries may die
WWW: <http://www.cs.mu.oz.au/~fjh>  |   but source code lives forever"
PGP: finger fjh at 128.250.37.3        |     -- leaked Microsoft memo.



More information about the developers mailing list