Y2K Countdown

Here, we're going to return a number of days until a specified event, in this case: January 1, 2000. With all the hulabaloo about Y2K compliance, we'll add in a jab at the PC camp by returning a different message about Y2k depending on the platform the request is coming from. How fun...

Name: Doomsday Clock

SSI: Y2KCLOCK

func(nullvar)

begin

//easily change the target date
//by altering this string

local thedate:= "January 1, 2000";

local leftstr;

local ldays;

//Get # minutes from thedate till now,
//divide by 60 minutes per hour
//divided by 24 hours per day then round down.

ldays:= Floor(StringToDate(thedate) - time())/60/24);

//Browsers usually transmit some platform info
//after their browser agent data. We'll look
//for 'Mac' in the text of the user-agent field.

if StrPos("HTTP_USER_AGENT", "Mac", 0) then

leftstr:= "'till D-day";

else

leftstr:= "to buy yourself a Macintosh!";

//Roll values together and return!

return ldays && "days left" && leftstr;

end