Set the date and time and script will count down. Displays in real time Float Text.
// ENTER YOUR DATE TO COUNTDOWN TO
integer aYear = 2012;
integer aMonth = 12; // 1 through 12
integer aDay = 21; // 1 through 31
integer aHour = 12; // 12 is noon
integer aMinute = 0; // 0 through 59
integer aSecond = 0; // 0 through 59
integer aGMToffset = -8; // -8 for the SL clock
integer DST = TRUE; // TRUE or FALSE depending on daylight savings time.
// END SETTINGS
// BEGIN SCRIPT
integer expires;
integer MakeUNIXTime( integer year, integer month, integer day, integer hour, integer minute, integer second, integer GMToffset, integer DST ) {
list month_days = [ 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 ];
integer time = ( year - 1970 ) * 31536000;
time += ( day + llList2Integer( month_days, month - 1 ) - 1 ) * 86400;
time += ( hour - GMToffset ) * 3600 + minute * 60 + second;
if ( DST == TRUE ) {
time += -3600;
}
if ( year > 1972 ) {
integer past_leap_years = (integer)( ( year - 1969 ) / 4 );
time += past_leap_years * 86400;
}
if ( year % 4 == 0 && month > 2 ) {
time += 86400;
}
return time;
}
default
{
on_rez( integer sparam )
{
llResetScript();
}
state_entry()
{
expires = MakeUNIXTime( aYear, aMonth, aDay, aHour, aMinute, aSecond, aGMToffset, DST );
llSetTimerEvent( 1.0 );
}
timer()
{
integer seconds = expires - llGetUnixTime();
if( seconds > 0 )
{
integer days = seconds / 86400;
integer hours = ( seconds - ( days * 86400 ) ) / 3600;
integer minutes = ( seconds - ( days * 86400 ) - ( hours * 3600 ) ) / 60;
seconds = ( seconds - ( days * 86400 ) - ( hours * 3600 ) - ( minutes * 60 ) );
string s1 = " Days, ";
if( days == 1 )
{
s1 = " Day, ";
}
string s2 = " Hours, & ";
if ( hours == 1 )
{
s2 = " Hour, ";
}
string s3 = " Minutes ";
if ( minutes == 1 )
{
s3 = " minute, ";
}
string s4 = " seconds ";
if ( seconds == 1 )
{
s4 = " second ";
}
llSetText( (string)days + s1 + (string)hours + s2 + (string)minutes + s3 + "Left", <1.0,1.0,1.0>, 1.0 ); //no seconds version
//llSetText( (string)days + s1 + (string)hours + s2 + (string)minutes + s3 + (string)seconds + s4 + "Left", <1.0,1.0,1.0>, 1.0 ); //with seconds
}
else
{
state expired;
}
}
}
state expired
{
on_rez( integer sparam )
{
llResetScript();
}
state_entry()
{
llSetText( " ", <1.0,1.0,1.0>, 1.0 );
}
}