web/lib/Zend/Gdata/App/Util.php
changeset 807 877f952ae2bd
parent 207 621fa6caec0c
child 1230 68c69c656a2c
equal deleted inserted replaced
805:5e7a0fedabdf 807:877f952ae2bd
    14  * to license@zend.com so we can send you a copy immediately.
    14  * to license@zend.com so we can send you a copy immediately.
    15  *
    15  *
    16  * @category   Zend
    16  * @category   Zend
    17  * @package    Zend_Gdata
    17  * @package    Zend_Gdata
    18  * @subpackage App
    18  * @subpackage App
    19  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
    19  * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
    20  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    20  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    21  * @version    $Id: Util.php 20096 2010-01-06 02:05:09Z bkarwin $
    21  * @version    $Id: Util.php 24643 2012-02-25 21:35:32Z adamlundrigan $
    22  */
    22  */
    23 
    23 
    24 /**
    24 /**
    25  * Utility class for static functions needed by Zend_Gdata_App
    25  * Utility class for static functions needed by Zend_Gdata_App
    26  *
    26  *
    27  * @category   Zend
    27  * @category   Zend
    28  * @package    Zend_Gdata
    28  * @package    Zend_Gdata
    29  * @subpackage App
    29  * @subpackage App
    30  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
    30  * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
    31  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    31  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    32  */
    32  */
    33 class Zend_Gdata_App_Util
    33 class Zend_Gdata_App_Util
    34 {
    34 {
    35 
    35 
    43     public static function formatTimestamp($timestamp)
    43     public static function formatTimestamp($timestamp)
    44     {
    44     {
    45         $rfc3339 = '/^(\d{4})\-?(\d{2})\-?(\d{2})((T|t)(\d{2})\:?(\d{2})' .
    45         $rfc3339 = '/^(\d{4})\-?(\d{2})\-?(\d{2})((T|t)(\d{2})\:?(\d{2})' .
    46                    '\:?(\d{2})(\.\d{1,})?((Z|z)|([\+\-])(\d{2})\:?(\d{2})))?$/';
    46                    '\:?(\d{2})(\.\d{1,})?((Z|z)|([\+\-])(\d{2})\:?(\d{2})))?$/';
    47 
    47 
    48         if (ctype_digit($timestamp)) {
    48         if (ctype_digit((string)$timestamp)) {
    49             return gmdate('Y-m-d\TH:i:sP', $timestamp);
    49             return gmdate('Y-m-d\TH:i:sP', $timestamp);
    50         } elseif (preg_match($rfc3339, $timestamp) > 0) {
    50         } elseif (preg_match($rfc3339, $timestamp) > 0) {
    51             // timestamp is already properly formatted
    51             // timestamp is already properly formatted
    52             return $timestamp;
    52             return $timestamp;
    53         } else {
    53         } else {