//Returns how many minutes to rollover
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
int MinutesToRollover()
{
//get the html source
string source = visit_url("charpane.php");
//the start of the rollover var
int ROS = index_of( source, "var rollover = " ) + length( "var rollover = " );
//the end of the rollover var
int ROE = index_of( source, ";", ROS );
//the start of the rightnow var
int RNS = index_of( source, "var rightnow = " ) + length( "var rightnow = " );
//the end of the rightnow var
int RNE = index_of( source, ";", RNS );
//the start of the rightnow var
//extract the string containing the number part of the start of rollover
string rollover = substring(source, ROS, ROE);
//extract the string containing the number part of kol's version of rightnow
string rightnow = substring(source, RNS, RNE);
return ( to_int( rollover ) - to_int( rightnow ) ) / 60;
}
// Get-Time by Alifar, EST none daylight savings time, rollover occurs at 23:30
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
string get_time()
{
int day_sec = 86400;
int hour_sec = 3600;
int minute_sec = 60;
buffer emptybuffer;
buffer timestamp_site = visit_url( "http://www.unixtimestamp.com/index.php" ); ## The sidepane has a timestamp in it, but it doesn't seem to update correctly.
if(timestamp_site == emptybuffer) return "Timestamp Unavailable At This Time:(";
int rightnow = index_of( timestamp_site , "<font color=" );
string timestamp = substring( timestamp_site , rightnow + 22 , rightnow + 32 );
int timestamp_int = timestamp.to_int();
int sec_since_midnight = timestamp_int % day_sec;
hour = ( ( sec_since_midnight - sec_since_midnight % hour_sec ) / hour_sec ) - 5;
if( hour < 0 )
{
hour = hour + 24;
}
sec_since_midnight = sec_since_midnight % hour_sec;
minute = ( ( sec_since_midnight - sec_since_midnight % minute_sec ) / minute_sec );
second = sec_since_midnight % minute_sec;
string minute_string = minute.to_string();
string second_string = second.to_string();
if( minute < 10 )
{
minute_string = "0" + minute.to_string();
}
if( second < 10 )
{
second_string = "0" + second.to_string();
}
string time = hour + ":" + minute_string + ":" + second_string;
return time;
}
string get_time(int seconds)
{
int day_sec = 86400;
int hour_sec = 3600;
int minute_sec = 60;
int timestamp_int = seconds;
int sec_since_midnight = timestamp_int % day_sec;
hour = ( ( sec_since_midnight - sec_since_midnight % hour_sec ) / hour_sec ) - 5;
if( hour < 0 )
{
hour = hour + 24;
}
sec_since_midnight = sec_since_midnight % hour_sec;
minute = ( ( sec_since_midnight - sec_since_midnight % minute_sec ) / minute_sec );
second = sec_since_midnight % minute_sec;
string minute_string = minute.to_string();
string second_string = second.to_string();
if( minute < 10 )
{
minute_string = "0" + minute.to_string();
}
if( second < 10 )
{
second_string = "0" + second.to_string();
}
string time = hour + ":" + minute_string + ":" + second_string;
return time;
}
//Return Hour
int get_hour()
{
get_time();
return hour;
}
//Return Minute
int get_minute()
{
get_time();
return minute;
}
//returns int for the day of the week
// 0 = Sunday
// 1 = Monday
// 2 = Tuesday
// 3 = Wednesday
// 4 = Thursday
// 5 = Friday
// 6 = Saturday
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
int day_of_week( )
{
string date = today_to_string();
int c = substring(date,0,2).to_int();
int y = substring(date,2,4).to_int();
int m = substring(date,4,6).to_int();
int d = substring(date, 6, 8 ).to_int();
if( m<3 ) //for Zeller's Rule march is the first month and febuary is last.
{
m=m+10;
y=y-1;
}
else m=m-2;
int temp1 = ( ( ( 13*m ) -1 ) /5 );
int temp2 = (y/4);
int temp3 = (C/4);
int f = d + temp1 + y + temp2 + temp3 - (2*C);
if ( f < 0 ){return (f % 7) + 7;}
return f % 7;
}
//Return string for the day of the Week
string Day()
{
switch (day_of_week( ))
{
case 0:
return "Sunday";
case 1:
return "Monday";
case 2:
return "Tuesday";
case 3:
return "Wednesday";
case 4:
return "Thursday";
case 5:
return "Friday";
case 6:
return "Saturday";
}
return "";
}