Source for file Timehash.php

Documentation is available at Timehash.php

  1. <?php
  2. /**
  3.  * Teeple2 - PHP5 Web Application Framework inspired by Seasar2
  4.  *
  5.  * PHP versions 5
  6.  *
  7.  * LICENSE: This source file is subject to version 3.0 of the PHP license
  8.  * that is available through the world-wide-web at the following URI:
  9.  * http://www.php.net/license/3_0.txt.  If you did not receive a copy of
  10.  * the PHP License and are unable to obtain it through the web, please
  11.  * send a note to license@php.net so we can mail you a copy immediately.
  12.  *
  13.  * @package     teeple
  14.  * @author      Mitsutaka Sato <miztaka@gmail.com>
  15.  * @license     http://www.php.net/license/3_0.txt  PHP License 3.0
  16.  */
  17.  
  18. /**
  19.  * 連想配列で渡された時刻から文字列を作成します。
  20.  * 時刻は Hour,Minute,Secondをキーとする連想配列に格納されている前提です。
  21.  * 時分は必須、秒は任意とします。
  22.  * target属性で指定されたフィールド名に値を格納します。
  23.  * format属性でフォーマットを指定できます。
  24.  *
  25.  * @package teeple.converter
  26.  */
  27. {
  28.     
  29.     /**
  30.      * 変換後の値を格納するプロパティ名
  31.      * @var string 
  32.      */
  33.     public $target;
  34.     
  35.     /**
  36.      * 変換する際のフォーマット(strftimeの形式)
  37.      * @var string 
  38.      */
  39.     public $format = "%H:%M:%S";
  40.     
  41.     protected function execute(&$obj$fieldName{
  42.         
  43.         if (Teeple_Util::isBlank($this->target)) {
  44.             throw new Teeple_Exception("targetが指定されていません。");
  45.         }
  46.         
  47.         $value Teeple_Util::getProperty($obj$fieldName);
  48.         if (is_array($value|| count($value2{
  49.             return FALSE;
  50.         }
  51.         
  52.         $h $value['Hour'];
  53.         $i $value['Minute'];
  54.         $s = isset($value['Second']$value['Second'0;
  55.         if ($h != "" && $i != ""{
  56.             $time mktime($h$i$s);
  57.             if ($time !== FALSE{
  58.                 $datestr strftime($this->format$time);
  59.                 Teeple_Util::setProperty($obj$this->target$datestr);
  60.                 return TRUE;
  61.             }
  62.         }
  63.         return FALSE;
  64.     }
  65.     
  66. }
  67. ?>

Documentation generated on Mon, 26 Apr 2010 08:59:59 +0900 by phpDocumentor 1.4.3