[insert_php]
ini_set(‚display_errors‘,1);
ini_set(‚display_startup_errors‘,1);
error_reporting(-1);
//This gets requested or today’s date and puts the day, month, and year in seperate variables
$date=$_GET[„date“];
if (!isset($date)) {
$date = time ();
$day = date(‚d‘, $date) ;
$month = date(‚m‘, $date) ;
$year = date(‚Y‘, $date) ;
}
else {
$day = 1 ;
$month = substr($date,-2,2);
$year = substr($date,-6,4) ;
}
//This checks validity of date
if (!checkdate($month,$day,$year)) {
$date = time ();
$day = 1;
$month = 1;
$year = 2009 ;
}
//Here we generate the first day of the month
$first_day = mktime(0,0,0,$month, 1, $year) ;
//We then determine how many days are in the current month
$days_in_month = cal_days_in_month(0, $month, $year) ;
if (month==12) $nextclickdate = mktime(0,0,0, 1, 1, $year+1);
else $nextclickdate = mktime(0,0,0,$month+1, 1, $year);
if (month==1) $prevclickdate = mktime(0,0,0, 12, 1, $year-1);
else $prevclickdate = mktime(0,0,0,$month-1, 1, $year);
//This gets us the month name
$title = date(‚F‘, $first_day);
$prevmonth = date(‚F‘, $prevclickdate);
$nextmonth = date(‚F‘, $nextclickdate);
$prevclickdate = date(‚Ym‘, $prevclickdate);
$nextclickdate = date(‚Ym‘, $nextclickdate);
//Here we find out what day of the week the first day of the month falls on
$day_of_week = date(‚D‘, $first_day) ;
//Once we know what day of the week it falls on, we know how many blank days occure before it. If the first day of the week is a Sunday then it would be zero
switch($day_of_week){
case „Sun“: $blank = 6; break;
case „Mon“: $blank = 0; break;
case „Tue“: $blank = 1; break;
case „Wed“: $blank = 2; break;
case „Thu“: $blank = 3; break;
case „Fri“: $blank = 4; break;
case „Sat“: $blank = 5; break;
}
//Here we start building the table heads
$title = ‚
|
‚.$title.‘ ‚.$year.‘ |
|
‚;
$title = str_replace („ary“,“ár“,$title);
$title = str_replace („March“,“Marec“,$title);
$title = str_replace („April“,“Apríl“,$title);
$title = str_replace („May“,“Máj“,$title);
$title = str_replace („June“,“Jún“,$title);
$title = str_replace („July“,“Júl“,$title);
$title = str_replace („October“,“Október“,$title);
echo $title.‘
Po | Ut | St | Št | Pi | So | Ne | |
‚.$day_num.‘ | ‚.$day_num.‘ | ||||||
„;
[/insert_php]