Source for file 13.php
Documentation is available at 13.php
* Description: same as 1.php, but using the PEAR::Date engine
* Notice the use of the CALENDAR_ENGINE constant, which
* switches the calculation "engine"
* Note: make sure PEAR::Date is a stable release!!!
return ((float) $usec + (float) $sec);
// Switch to PEAR::Date engine
define('CALENDAR_ENGINE','PearDate');
if ( !@include 'Calendar/Calendar.php' ) {
define ('CALENDAR_ROOT','../../');
if (!isset ($_GET['y'])) $_GET['y'] = 2003;
if (!isset ($_GET['m'])) $_GET['m'] = 8;
if (!isset ($_GET['d'])) $_GET['d'] = 9;
if (!isset ($_GET['h'])) $_GET['h'] = 12;
if (!isset ($_GET['i'])) $_GET['i'] = 34;
if (!isset ($_GET['s'])) $_GET['s'] = 46;
switch ( @$_GET['view'] ) {
$_GET['view'] = 'calendar_year';
require_once CALENDAR_ROOT. 'Year.php';
require_once CALENDAR_ROOT. 'Month.php';
require_once CALENDAR_ROOT. 'Day.php';
require_once CALENDAR_ROOT. 'Hour.php';
$c = new Calendar_Hour($_GET['y'],$_GET['m'],$_GET['d'],$_GET['h']);
require_once CALENDAR_ROOT. 'Minute.php';
$c = new Calendar_Minute($_GET['y'],$_GET['m'],$_GET['d'],$_GET['h'],$_GET['i']);
require_once CALENDAR_ROOT. 'Second.php';
$c = new Calendar_Second($_GET['y'],$_GET['m'],$_GET['d'],$_GET['h'],$_GET['i'],$_GET['s']);
// Convert timestamp to human readable date
$date = new Date ($c->getTimestamp ());
echo ( '<h1>Using PEAR::Date engine</h1>' );
echo ( 'Viewing: '. @$_GET['view']. '<br />' );
echo ( 'The time is now: '. $date->format ('%Y %a %e %T'). '<br >' );
echo ( '<h1>First Iteration</h1>' );
echo ( '<p>The first iteration is more "expensive", the calendar data
structures having to be built.</p>' );
while ( $e = $c->fetch () ) {
$link = "&y=". $e->thisYear (). "&m=". $e->thisMonth (). "&d=". $e->thisDay ().
"&h=". $e->thisHour (). "&i=". $e->thisMinute (). "&s=". $e->thisSecond ();
echo ( "<a href=\"". $_SERVER['PHP_SELF']. "?view=". $class. $link. "\">". $e->{$method}(). "</a> : " );
echo ( '<p><b>Took: '. (getmicrotime()- $start). ' seconds</b></p>' );
echo ( '<h1>Second Iteration</h1>' );
echo ( '<p>This second iteration is faster, the data structures
while ( $e = $c->fetch () ) {
$link = "&y=". $e->thisYear (). "&m=". $e->thisMonth (). "&d=". $e->thisDay ().
"&h=". $e->thisHour (). "&i=". $e->thisMinute (). "&s=". $e->thisSecond ();
echo ( "<a href=\"". $_SERVER['PHP_SELF']. "?view=". $class. $link. "\">". $e->{$method}(). "</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.
|