Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/lib/zend/Zend/XmlRpc/Value/DateTime.php
Go to the documentation of this file.
00001 <?php
00027 require_once 'Zend/XmlRpc/Value/Scalar.php';
00028 
00029 
00037 class Zend_XmlRpc_Value_DateTime extends Zend_XmlRpc_Value_Scalar
00038 {
00044     protected $_phpFormatString = 'Ymd\\TH:i:s';
00045 
00051     protected $_isoFormatString = 'YYYYMMddTHH:mm:ss';
00052 
00061     public function __construct($value)
00062     {
00063         $this->_type = self::XMLRPC_TYPE_DATETIME;
00064 
00065         if ($value instanceof Zend_Date) {
00066             $this->_value = $value->toString($this->_isoFormatString);
00067         } elseif ($value instanceof DateTime) {
00068             $this->_value = $value->format($this->_phpFormatString);
00069         } elseif (is_numeric($value)) { // The value is numeric, we make sure it is an integer
00070             $this->_value = date($this->_phpFormatString, (int)$value);
00071         } else {
00072             $timestamp = strtotime($value);
00073             if ($timestamp === false || $timestamp == -1) { // cannot convert the value to a timestamp
00074                 require_once 'Zend/XmlRpc/Value/Exception.php';
00075                 throw new Zend_XmlRpc_Value_Exception('Cannot convert given value \''. $value .'\' to a timestamp');
00076             }
00077 
00078             $this->_value = date($this->_phpFormatString, $timestamp); // Convert the timestamp to iso8601 format
00079         }
00080     }
00081 
00087     public function getValue()
00088     {
00089         return $this->_value;
00090     }
00091 }
 All Data Structures Namespaces Files Functions Variables Enumerations