Ejemplo n.º 1
0
        break;
    case 'calendar_hour':
        require_once CALENDAR_ROOT . 'Hour.php';
        $c = new Calendar_Hour($_GET['y'], $_GET['m'], $_GET['d'], $_GET['h']);
        break;
    case 'calendar_minute':
        require_once CALENDAR_ROOT . 'Minute.php';
        $c = new Calendar_Minute($_GET['y'], $_GET['m'], $_GET['d'], $_GET['h'], $_GET['i']);
        break;
    case 'calendar_second':
        require_once CALENDAR_ROOT . 'Second.php';
        $c = new Calendar_Second($_GET['y'], $_GET['m'], $_GET['d'], $_GET['h'], $_GET['i'], $_GET['s']);
        break;
}
echo 'Viewing: ' . @$_GET['view'] . '<br />';
echo 'The time is now: ' . date('Y M d H:i:s', $c->getTimestamp()) . '<br >';
$i = 1;
echo '<h1>First Iteration</h1>';
echo '<p>The first iteration is more "expensive", the calendar data
        structures having to be built.</p>';
$start = getmicrotime();
$c->build();
while ($e = $c->fetch()) {
    $class = strtolower(get_class($e));
    $link = "&y=" . $e->thisYear() . "&m=" . $e->thisMonth() . "&d=" . $e->thisDay() . "&h=" . $e->thisHour() . "&i=" . $e->thisMinute() . "&s=" . $e->thisSecond();
    $method = 'this' . str_replace('calendar_', '', $class);
    echo "<a href=\"" . $_SERVER['PHP_SELF'] . "?view=" . $class . $link . "\">" . $e->{$method}() . "</a> : ";
    if ($i % 10 == 0) {
        echo '<br>';
    }
    $i++;
Ejemplo n.º 2
0
        break;
    case 'calendar_hour':
        require_once CALENDAR_ROOT . 'Hour.php';
        $c = new Calendar_Hour($_GET['y'], $_GET['m'], $_GET['d'], $_GET['h']);
        break;
    case 'calendar_minute':
        require_once CALENDAR_ROOT . 'Minute.php';
        $c = new Calendar_Minute($_GET['y'], $_GET['m'], $_GET['d'], $_GET['h'], $_GET['i']);
        break;
    case 'calendar_second':
        require_once CALENDAR_ROOT . 'Second.php';
        $c = new Calendar_Second($_GET['y'], $_GET['m'], $_GET['d'], $_GET['h'], $_GET['i'], $_GET['s']);
        break;
}
// 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 >';
$i = 1;
echo '<h1>First Iteration</h1>';
echo '<p>The first iteration is more "expensive", the calendar data
        structures having to be built.</p>';
$start = getmicrotime();
$c->build();
while ($e = $c->fetch()) {
    $class = strtolower(get_class($e));
    $link = "&y=" . $e->thisYear() . "&m=" . $e->thisMonth() . "&d=" . $e->thisDay() . "&h=" . $e->thisHour() . "&i=" . $e->thisMinute() . "&s=" . $e->thisSecond();
    $method = 'this' . str_replace('calendar_', '', $class);
    echo "<a href=\"" . $_SERVER['PHP_SELF'] . "?view=" . $class . $link . "\">" . $e->{$method}() . "</a> : ";
    if ($i % 10 == 0) {