#!/usr/bin/perl
# Time-stamp: "2005-08-19 01:51:22 ADT"
# desc  {  CGI reporting how long until next Christmas   }
#
# christmas countdown.  Sean M. Burke sburke@cpan.org, 10/03/96

die unless require("timelocal.pl");

@now = gmtime(time());
@xmas = @now; # now let's change it
@xmas[0 .. 4] = (0,0,0,25,11); # when Xmas is.
$xmas[5]++ if ($now[3] >= $xmas[3] and $now[4] == $xmas[4]);

$days = int((timelocal(@xmas[0 .. 5]) - time()) / (60 * 60 * 24));
if ($days == 1) {
    $days .= ' shopping day';
} else {
    $days .= ' shopping days';
}
$message = "Only $days left until Christmas!";

if ($ENV{'SCRIPT_NAME'} eq '') { #I'm not a CGI
    print $message . "\n";
} else { #I'm a CGI
    print "Content-Type: text/html\n\n" . 
    "<HTML><HEAD><TITLE>Xmas Countdown</TITLE></HEAD>\n" .
    '</HEAD><BODY BGCOLOR="#ff0000"  TEXT="#ffffff">' .
    '<CENTER><BLINK><FONT SIZE="+4"><B><I>' .
    "$message</I></B></FONT></BLINK></CENTER></BODY></HTML>";
    # fugly codes
}

1;

#
## end
