Source for file Todatetimehash.php

Documentation is available at Todatetimehash.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.  * 日時の文字列から連想配列を作成します。(Datetimehashの逆)
  20.  * 日時は Year,Month,Day,Hour,Minute,Secondをキーとする連想配列に格納されます。
  21.  * 日付は必須、時刻は任意とします。
  22.  * 日付のフォーマットは "%Y-%m-%d %H:%M:%S"
  23.  * target属性で指定されたフィールド名に値を格納します。
  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 = "%Y-%m-%d %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.         $result array();
  48.         $value Teeple_Util::getProperty($obj$fieldName);
  49.         
  50.         list($day$timeexplode(' '$value);
  51.         if (Teeple_Util::isBlank($day)) {
  52.             return FALSE;
  53.         }
  54.         list($y,$m,$dexplode('-'$day);
  55.         $result['Year'$y;
  56.         $result['Month'$m;
  57.         $result['Day'$d;
  58.         
  59.         if (Teeple_Util::isBlank($time)) {
  60.             list($h$i$sexplode(':'$time);
  61.             $result['Hour'$h;
  62.             $result['Minute'$i;
  63.             $result['Second'$s;
  64.         }
  65.         
  66.         Teeple_Util::setProperty($obj$this->target$result);
  67.         return TRUE;
  68.     }
  69.     
  70. }
  71. ?>

Documentation generated on Mon, 26 Apr 2010 09:00:00 +0900 by phpDocumentor 1.4.3