Source for file 5.php
Documentation is available at 5.php
* Description: generating elements of a form with PEAR::Calendar, using
* selections as well as validating the submission
return ((float) $usec + (float) $sec);
if ( !@include 'Calendar/Calendar.php' ) {
define ('CALENDAR_ROOT','../../');
require_once CALENDAR_ROOT. 'Year.php';
require_once CALENDAR_ROOT. 'Month.php';
require_once CALENDAR_ROOT. 'Day.php';
require_once CALENDAR_ROOT. 'Hour.php';
require_once CALENDAR_ROOT. 'Minute.php';
require_once CALENDAR_ROOT. 'Second.php';
if (!isset ($_POST['y'])) $_POST['y'] = date('Y');
if (!isset ($_POST['m'])) $_POST['m'] = date('n');
if (!isset ($_POST['d'])) $_POST['d'] = date('j');
if (!isset ($_POST['h'])) $_POST['h'] = date('H');
if (!isset ($_POST['i'])) $_POST['i'] = date('i');
if (!isset ($_POST['s'])) $_POST['s'] = date('s');
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<title> Select and Update </title>
<h1>Select and Update</h1>
if ( isset ($_POST['update']) ) {
$Second = & new Calendar_Second($_POST['y'],$_POST['m'],$_POST['d'],$_POST['h'],$_POST['i'],$_POST['s']);
if ( !$Second->isValid () ) {
$V= & $Second->getValidator ();
echo ('<p>Validation failed:</p>' );
while ( $error = $V->fetch () ) {
echo ( $error->toString () . '<br>' );
echo ('<p>Validation success.</p>' );
echo ( '<p>New timestamp is: '. $Second->getTimeStamp (). ' which could be used to update a database, for example');
$Day = new Calendar_Day($_POST['y'],$_POST['m'],$_POST['d']);
$Hour = new Calendar_Hour($_POST['y'],$_POST['m'],$_POST['d'],$_POST['h']);
$Minute = new Calendar_Minute($_POST['y'],$_POST['m'],$_POST['d'],$_POST['h'],$_POST['i']);
$Second = new Calendar_Second($_POST['y'],$_POST['m'],$_POST['d'],$_POST['h'],$_POST['i'],$_POST['s']);
<p><b>Set the alarm clock</p></p>
<form action=" <?php echo ( $_SERVER['PHP_SELF'] ); ?>" method="post">
Year: <input type="text" name="y" value=" <?php echo ( $_POST['y'] ); ?>" size="4">
$selection = array ($Month);
$Year->build ($selection);
while ( $Child = & $Year->fetch () ) {
if ( $Child->isSelected () ) {
echo ( "<option value=\"". $Child->thisMonth (). "\" selected>". $Child->thisMonth (). "\n" );
echo ( "<option value=\"". $Child->thisMonth (). "\">". $Child->thisMonth (). "\n" );
$selection = array ($Day);
$Month->build ($selection);
while ( $Child = & $Month->fetch () ) {
if ( $Child->isSelected () ) {
echo ( "<option value=\"". $Child->thisDay (). "\" selected>". $Child->thisDay (). "\n" );
echo ( "<option value=\"". $Child->thisDay (). "\">". $Child->thisDay (). "\n" );
$selection = array ($Hour);
while ( $Child = & $Day->fetch () ) {
if ( $Child->isSelected () ) {
echo ( "<option value=\"". $Child->thisHour (). "\" selected>". $Child->thisHour (). "\n" );
echo ( "<option value=\"". $Child->thisHour (). "\">". $Child->thisHour (). "\n" );
$selection = array ($Minute);
$Hour->build ($selection);
while ( $Child = & $Hour->fetch () ) {
if ( $Child->isSelected () ) {
echo ( "<option value=\"". $Child->thisMinute (). "\" selected>". $Child->thisMinute (). "\n" );
echo ( "<option value=\"". $Child->thisMinute (). "\">". $Child->thisMinute (). "\n" );
$selection = array ($Second);
$Minute->build ($selection);
while ( $Child = & $Minute->fetch () ) {
if ( $Child->isSelected () ) {
echo ( "<option value=\"". $Child->thisSecond (). "\" selected>". $Child->thisSecond (). "\n" );
echo ( "<option value=\"". $Child->thisSecond (). "\">". $Child->thisSecond (). "\n" );
<input type="submit" name="update" value="Set Alarm"><br>
<?php 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.
|