Source for file 2.php
Documentation is available at 2.php
* Description: Demonstrates building a calendar for a month using the Week class
return ((float) $usec + (float) $sec);
// Force UnixTs engine (default setting)
define('CALENDAR_ENGINE','UnixTS');
if (!@include 'Calendar'.DIRECTORY_SEPARATOR. 'Calendar.php') {
define ('CALENDAR_ROOT', '../../');
require_once CALENDAR_ROOT. 'Month/Weeks.php';
require_once CALENDAR_ROOT. 'Day.php';
// Initialize GET variables if not set
if (!isset ($_GET['y'])) $_GET['y'] = date('Y');
if (!isset ($_GET['m'])) $_GET['m'] = date('m');
if (!isset ($_GET['d'])) $_GET['d'] = date('d');
// Create an array of days which are "selected"
// Used for Week::build() below
// Instruct month to build Week objects
// Construct strings for next/previous links
$PMonth = $Month->prevMonth ('object'); // Get previous month as object
$prev = $_SERVER['PHP_SELF']. '?y='. $PMonth->thisYear (). '&m='. $PMonth->thisMonth (). '&d='. $PMonth->thisDay ();
$NMonth = $Month->nextMonth ('object');
$next = $_SERVER['PHP_SELF']. '?y='. $NMonth->thisYear (). '&m='. $NMonth->thisMonth (). '&d='. $NMonth->thisDay ();
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN">
<title> Calendar </title>
background-color: silver;
background-color: yellow;
<h2>Build with Calendar_Month_Weeks::build() then Calendar_Week::build()</h2>
<?php echo date('F Y', $Month->getTimeStamp ()); ?>
while ($Week = $Month->fetch ()) {
// Build the days in the week, passing the selected days
$Week->build ($selectedDays);
while ($Day = $Week->fetch ()) {
// Build a link string for each day
$link = $_SERVER['PHP_SELF'].
// Check to see if day is selected
if ($Day->isSelected ()) {
echo '<td class="selected">'. $Day->thisDay (). '</td>'. "\n";
// Check to see if day is empty
} else if ($Day->isEmpty ()) {
echo '<td class="empty">'. $Day->thisDay (). '</td>'. "\n";
echo '<td><a href="'. $link. '">'. $Day->thisDay (). '</a></td>'. "\n";
<a href=" <?php echo $prev; ?>" class="prevMonth"><< </a>
<td colspan="5"> </td>
<a href=" <?php echo $next; ?>" class="nextMonth"> >></a>
echo '<p><b>Took: '. (getmicrotime()- $start). ' seconds</b></p>';
Documentation generated on Mon, 11 Mar 2019 15:37:47 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|