Y2K

greenspun.com : LUSENET : S-Mart Shopping Cart : One Thread

Hi,

What about a Y2K version! Orders received with netscape are dated 19100, I tried to change a line in the smart.cgi file

localtime(time); if ($hour < 10) { $hour = "0$hour"; } if ($min < 10) { $min = "0$min"; } if ($sec < 10) { $sec = "0$sec"; } if ($year < 2000) {$year = $year + 1900;}

The date now is working fine, but the shopping cart add products all the time. Customers order 1 product, they have 1 product in the cart, but when they send the order, for some reasons I receive the order with several products added. I suppose the line that I added cleared the Y2K problem to create another one.

-- Luigi (info@hollywoodfactory.com), March 18, 2000

Answers

Localtime(time); returns 100 for the year 2000. So the test (control structure) if ($year < 2000) {$year = $year + 1900;} isn't neccessary. Just add 1900 as in:

sub get_date {

($sec,$min,$hour,$mday,$mon,$year,$wday) = localtime(time);

$year = $year + 1900;

$date = "$mon/$mday/$year";

}

Greg Swofford

-- Gregory Swofford (computer@web-store.net), March 18, 2000.


Moderation questions? read the FAQ