Hi

I've just written a countdown script in perl which is supposed to print how many days, hours, minutes and seconds there are left until a certain date (Specified in the first variables). The code is as following:
$yr = 2006;
$mo = 4;
$da = 13;
$hr = 0;
$min = 00;
$sec = 00;
$occasion="TG06!";
$message_on_occasion="The Gathering 06 er her!";
sub count()
{
@today=localtime(time());
$todayy=@today [5];
if ($todayy < 1000)
{
$todayy+=1900;
}
$todaym=@today [4];
$todayd=@today [3];
$todayh=@today [2];
$todaymin=@today [1];
$todaysec=@today [0];
$dd=($sec + ($min*60) + ($hr*3600) + ($da*3600*24) + ($mo*365/12*24*3600) + ($yr*365*24*3600)) - ($todaysec + ($todaymin*60) + ($todayhr*3600) + ($todayda*3600*24) + ($todaymo*365/12*24*3600) + ($todayyr*365*24*3600));
$dday=int($dd/(60*60*1000*24)*1);
$dhour=int(($dd%(60*60*1000*24))/(60*60*1000)*1);
$dmin=int((($dd%(60*60*1000*24))%(60*60*1000))/(60*1000)*1);
$dsec=int((((dd%(60*60*1000*24))%(60*60*1000))%(60*1000))/1000*1);
system "cls";
if ($dday<=0&&$dhour<=0&&$dmin<=0&&$dsec<=1&&$todayd==$da)
{print $message_on_occasion;}
elsif ($dday<=-1)
{print $occasion+" er i gang, eller kanskje til og med ferdig :( Da er det bare å vente til neste år :D";}
else
{print "Det er "+$dday+" dager, "+$dhour+" timer, "+$dmin+" minutter og "+$dsec+" sekunder igjen til "+$occasion;}
sleep 1;
count();
}
count();
|