3 * Description: Performs same behaviour as 2.php but uses Month::buildWeekDays()
6 function getmicrotime(){
7 list($usec, $sec) = explode(" ",microtime());
8 return ((float)$usec + (float)$sec);
10 $start = getmicrotime();
12 if ( !@include 'Calendar/Calendar.php' ) {
13 define('CALENDAR_ROOT','../../');
15 require_once CALENDAR_ROOT.'Month/Weekdays.php';
16 require_once CALENDAR_ROOT.'Day.php';
18 if (!isset($_GET['y'])) $_GET['y'] = date('Y');
19 if (!isset($_GET['m'])) $_GET['m'] = date('m');
20 if (!isset($_GET['d'])) $_GET['d'] = date('d');
23 $Month = new Calendar_Month_Weekdays($_GET['y'],$_GET['m']);
25 // Construct strings for next/previous links
26 $PMonth = $Month->prevMonth('object'); // Get previous month as object
27 $prev = $_SERVER['PHP_SELF'].'?y='.$PMonth->thisYear().'&m='.$PMonth->thisMonth().'&d='.$PMonth->thisDay();
28 $NMonth = $Month->nextMonth('object');
29 $next = $_SERVER['PHP_SELF'].'?y='.$NMonth->thisYear().'&m='.$NMonth->thisMonth().'&d='.$NMonth->thisDay();
31 <!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN">
34 <title> Calendar </title>
35 <style text="text/css">
37 background-color: silver;
42 background-color: while;
64 background-color: yellow;
72 $selectedDays = array (
73 new Calendar_Day($_GET['y'],$_GET['m'],$_GET['d']),
74 new Calendar_Day($_GET['y'],12,25),
77 // Build the days in the month
78 $Month->build($selectedDays);
80 <h2>Built with Calendar_Month_Weekday::build()</h2>
81 <table class="calendar">
83 <?php echo ( date('F Y',$Month->getTimeStamp())); ?>
95 while ( $Day = $Month->fetch() ) {
97 // Build a link string for each day
98 $link = $_SERVER['PHP_SELF'].
99 '?y='.$Day->thisYear().
100 '&m='.$Day->thisMonth().
101 '&d='.$Day->thisDay();
103 // isFirst() to find start of week
104 if ( $Day->isFirst() )
107 if ( $Day->isSelected() ) {
108 echo ( "<td class=\"selected\">".$Day->thisDay()."</td>\n" );
109 } else if ( $Day->isEmpty() ) {
110 echo ( "<td> </td>\n" );
112 echo ( "<td><a href=\"".$link."\">".$Day->thisDay()."</a></td>\n" );
115 // isLast() to find end of week
116 if ( $Day->isLast() )
122 <a href="<?php echo ($prev);?>" class="prevMonth"><< </a>
124 <td colspan="5"> </td>
126 <a href="<?php echo ($next);?>" class="nextMonth"> >></a>
131 echo ( '<p><b>Took: '.(getmicrotime()-$start).' seconds</b></p>' );