Source for file Datearray.php

Documentation is available at Datearray.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.  * 年月日はそれぞれ、$foo[0],$foo[1],$foo[2]に格納されている前提です。
  21.  * target属性で指定されたフィールド名に値を格納します。
  22.  * format属性でフォーマットを指定できます。
  23.  *
  24.  * @package teeple.converter
  25.  */
  26. {
  27.     
  28.     /**
  29.      * 変換後の値を格納するプロパティ名
  30.      * @var string 
  31.      */
  32.     public $target;
  33.     
  34.     /**
  35.      * 変換する際のフォーマット(strftimeの形式)
  36.      * @var string 
  37.      */
  38.     public $format = "%Y-%m-%d";
  39.     
  40.     protected function execute(&$obj$fieldName{
  41.         
  42.         if (Teeple_Util::isBlank($this->target)) {
  43.             throw new Teeple_Exception("targetが指定されていません。");
  44.         }
  45.         
  46.         $value Teeple_Util::getProperty($obj$fieldName);
  47.         if (is_array($value|| count($value!= 3{
  48.             return FALSE;
  49.         }
  50.         
  51.         if ($value[0!= "" && $value[1!= "" && $value[2!= ""{
  52.             $time mktime(0,0,0,$value[1],$value[2],$value[0]);
  53.             if ($time !== FALSE{
  54.                 $datestr strftime($this->format$time);
  55.                 Teeple_Util::setProperty($obj$this->target$datestr);
  56.                 return TRUE;
  57.             }
  58.             
  59.         }
  60.         return FALSE;
  61.     }
  62.     
  63. }
  64. ?>

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