当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Date_DateObject类代码示例

本文整理汇总了PHP中Zend_Date_DateObject的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Date_DateObject类的具体用法?PHP Zend_Date_DateObject怎么用?PHP Zend_Date_DateObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Zend_Date_DateObject类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: dayOfWeekHelper

 public function dayOfWeekHelper($y, $m, $d)
 {
     return Zend_Date_DateObject::dayOfWeek($y, $m, $d);
 }
开发者ID:baofeng-beijing,项目名称:zf1.11.x,代码行数:4,代码来源:DateObjectTest.php

示例2: setOptions

 /**
  * Sets class wide options, if no option was given, the actual set options will be returned
  *
  * @param  array  $options  Options to set
  * @throws \Zend\Date\Exception
  * @return Options array if no option was given
  */
 public static function setOptions(array $options = array())
 {
     if (empty($options)) {
         return self::$_options;
     }
     foreach ($options as $name => $value) {
         $name = strtolower($name);
         if (array_key_exists($name, self::$_options)) {
             switch ($name) {
                 case 'format_type':
                     if (strtolower($value) != 'php' && strtolower($value) != 'iso') {
                         throw new Exception\InvalidArgumentException("Unknown format type ({$value}) for dates, only 'iso' and 'php' supported");
                         /*, 0, null, $value */
                     }
                     break;
                 case 'fix_dst':
                     if (!is_bool($value)) {
                         throw new Exception\InvalidArgumentException("'fix_dst' has to be boolean");
                         /* , 0, null, $value */
                     }
                     break;
                 case 'extend_month':
                     if (!is_bool($value)) {
                         throw new Exception\InvalidArgumentException("'extend_month' has to be boolean");
                         /* ); */
                     }
                     break;
                 case 'cache':
                     if ($value === null) {
                         parent::$_cache = null;
                     } else {
                         if (!$value instanceof \Zend\Cache\Frontend) {
                             throw new Exception\InvalidArgumentException("Instance of Zend_Cache expected");
                         }
                         parent::$_cache = $value;
                         parent::$_cacheTags = Zend_Date_DateObject::hasCacheTagSupport();
                         Cldr::setCache($value);
                     }
                     break;
                 case 'timesync':
                     if ($value === null) {
                         parent::$_defaultOffset = 0;
                     } else {
                         if (!$value instanceof TimeSync\Protocol) {
                             throw new Exception\InvalidArgumentException("Instance of Zend_TimeSync expected for option timesync");
                         }
                         $date = $value->getInfo();
                         parent::$_defaultOffset = $date['offset'];
                     }
                     break;
             }
             self::$_options[$name] = $value;
         } else {
             throw new Exception\InvalidArgumentException("Unknown option: {$name} = {$value}");
         }
     }
 }
开发者ID:navtis,项目名称:xerxes-pazpar2,代码行数:64,代码来源:Date.php

示例3: mktime

 /**
  * Get unix timestamp.
  * Added limitation: $year value must be between -10 000 and 10 000
  * Parent method implementation causes 504 error if it gets too big(small) year value
  *
  * @see Zend_Date_DateObject::mktime
  * @throws Zend_Date_Exception
  * @param $hour
  * @param $minute
  * @param $second
  * @param $month
  * @param $day
  * @param $year
  * @param bool $gmt
  * @return float|int
  */
 protected function mktime($hour, $minute, $second, $month, $day, $year, $gmt = false)
 {
     $day = intval($day);
     $month = intval($month);
     $year = intval($year);
     // correct months > 12 and months < 1
     if ($month > 12) {
         $overlap = floor($month / 12);
         $year += $overlap;
         $month -= $overlap * 12;
     } else {
         $overlap = ceil((1 - $month) / 12);
         $year -= $overlap;
         $month += $overlap * 12;
     }
     if ($year > self::YEAR_MAX_VALUE || $year < self::YEAR_MIN_VALUE) {
         throw new Zend_Date_Exception('Invalid year, it must be between ' . self::YEAR_MIN_VALUE . ' and ' . self::YEAR_MAX_VALUE);
     }
     return parent::mktime($hour, $minute, $second, $month, $day, $year, $gmt);
 }
开发者ID:newedge-media,项目名称:medpage-easylink,代码行数:36,代码来源:__checkout.php

示例4: testDate

 public function testDate()
 {
     $date = new Zend_Date_DateObject(0);
     $this->assertTrue($date->date('U') > 0);
     $this->assertSame($date->date('U', 0), '0');
     $this->assertSame($date->date('U', 0, false), '0');
     $this->assertSame($date->date('U', 0, true), '0');
     $this->assertSame($date->date('U', 6900000000), '6900003600');
     $this->assertSame($date->date('U', -7000000000), '-6999996400');
     $this->assertSame($date->date('d', -7000000000), '06');
     $this->assertSame($date->date('D', -7000000000), 'Wed');
     $this->assertSame($date->date('j', -7000000000), '6');
     $this->assertSame($date->date('l', -7000000000), 'Wednesday');
     $this->assertSame($date->date('N', -7000000000), '3');
     $this->assertSame($date->date('S', -7000000000), 'th');
     $this->assertSame($date->date('w', -7000000000), '3');
     $this->assertSame($date->date('z', -7000000000), '65');
     $this->assertSame($date->date('W', -7000000000), '10');
     $this->assertSame($date->date('F', -7000000000), 'March');
     $this->assertSame($date->date('m', -7000000000), '03');
     $this->assertSame($date->date('M', -7000000000), 'Mar');
     $this->assertSame($date->date('n', -7000000000), '3');
     $this->assertSame($date->date('t', -7000000000), '31');
     $this->assertSame($date->date('T', -7000000000), 'CET');
     $this->assertSame($date->date('L', -7000000000), '1');
     $this->assertSame($date->date('o', -7000000000), '1748');
     $this->assertSame($date->date('Y', -7000000000), '1748');
     $this->assertSame($date->date('y', -7000000000), '48');
     $this->assertSame($date->date('a', -7000000000), 'pm');
     $this->assertSame($date->date('A', -7000000000), 'PM');
     $this->assertSame($date->date('B', -7000000000), '523');
     $this->assertSame($date->date('g', -7000000000), '12');
     $this->assertSame($date->date('G', -7000000000), '12');
     $this->assertSame($date->date('h', -7000000000), '12');
     $this->assertSame($date->date('H', -7000000000), '12');
     $this->assertSame($date->date('i', -7000000000), '33');
     $this->assertSame($date->date('s', -7000000000), '20');
     $this->assertSame($date->date('e', -7000000000), 'Europe/Paris');
     $this->assertSame($date->date('I', -7000000000), '0');
     $this->assertSame($date->date('O', -7000000000), '+0100');
     $this->assertSame($date->date('P', -7000000000), '+01:00');
     $this->assertSame($date->date('T', -7000000000), 'CET');
     $this->assertSame($date->date('Z', -7000000000), '3600');
     $this->assertSame($date->date('c', -7000000000), '1748-3-06T12:33:20+01:00');
     $this->assertSame($date->date('r', -7000000000), 'Wed, 06 Mar 1748 12:33:20 +0100');
     $this->assertSame($date->date('U', -7000000000), '-6999996400');
     $this->assertSame($date->date('\\H', -7000000000), 'H');
     $this->assertSame($date->date('.', -7000000000), '.');
     $this->assertSame($date->date('H:m:s', -7000000000), '12:03:20');
     $this->assertSame($date->date('d-M-Y', -7000000000), '06-Mar-1748');
     $this->assertSame($date->date('U', 6900000000, true), '6900000000');
     $this->assertSame($date->date('B', 6900000000, true), '152');
     $this->assertSame($date->date('g', 6899993000, true), '12');
     $this->assertSame($date->date('g', 6899997000, true), '1');
     $this->assertSame($date->date('g', 6900039200, true), '1');
     $this->assertSame($date->date('h', 6899993000, true), '12');
     $this->assertSame($date->date('h', 6899997000, true), '01');
     $this->assertSame($date->date('h', 6900040200, true), '01');
     $this->assertSame($date->date('e', -7000000000, true), 'UTC');
     $this->assertSame($date->date('I', -7000000000, true), '0');
     $this->assertSame($date->date('T', -7000000000, true), 'GMT');
     $this->assertSame($date->date('N', 6899740800, true), '6');
     $this->assertSame($date->date('S', 6900518000, true), 'st');
     $this->assertSame($date->date('S', 6900604800, true), 'nd');
     $this->assertSame($date->date('S', 6900691200, true), 'rd');
     $this->assertSame($date->date('N', 6900432000, true), '7');
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:67,代码来源:DateObjectTest.php

示例5: checkLeapYear

 /**
  * Check a given year for leap year.
  *
  * @param  integer|array|Zend_Date  $year  Year to check
  * @return boolean
  */
 public static function checkLeapYear($year)
 {
     if ($year instanceof Zend_Date) {
         $year = (int) $year->toString(self::YEAR, 'iso');
     }
     if (is_array($year)) {
         if (isset($year['year']) === true) {
             $year = $year['year'];
         } else {
             require_once 'Zend/Date/Exception.php';
             throw new Zend_Date_Exception("no year given in array");
         }
     }
     if (!is_numeric($year)) {
         require_once 'Zend/Date/Exception.php';
         throw new Zend_Date_Exception("year ({$year}) has to be integer for checkLeapYear()", 0, null, $year);
     }
     return (bool) parent::isYearLeapYear($year);
 }
开发者ID:arendasistemasintegrados,项目名称:mateusleme,代码行数:25,代码来源:Date.php

示例6: _getTagSupportForCache

 /**
  * Internal method to check if the given cache supports tags
  *
  * @param Zend_Cache $cache
  */
 protected static function _getTagSupportForCache()
 {
     $backend = self::$_cache->getBackend();
     if ($backend instanceof Zend_Cache_Backend_ExtendedInterface) {
         $cacheOptions = $backend->getCapabilities();
         self::$_cacheTags = $cacheOptions['tags'];
     } else {
         self::$_cacheTags = false;
     }
     return self::$_cacheTags;
 }
开发者ID:SalesOneGit,项目名称:s1_magento,代码行数:16,代码来源:DateObject.php

示例7: checkLeapYear

 /**
  * Check a given year for leap year.
  *
  * @param  integer|array|Zend_Date  $year  Year to check
  * @return boolean
  */
 public static function checkLeapYear($year)
 {
     if ($year instanceof Zend_Date) {
         $year = (int) $year->get(Zend_Date::YEAR);
     }
     if (is_array($year)) {
         if (array_key_exists('year', $year)) {
             $year = $year['year'];
         } else {
             require_once 'Zend/Date/Exception.php';
             throw new Zend_Date_Exception("no year given in array");
         }
     }
     if (!is_numeric($year)) {
         require_once 'Zend/Date/Exception.php';
         throw new Zend_Date_Exception("year ({$year}) has to be integer for checkLeapYear()", $year);
     }
     return (bool) parent::isYearLeapYear($year);
 }
开发者ID:dalinhuang,项目名称:popo,代码行数:25,代码来源:Date.php

示例8: checkLeapYear

 /**
  * Check a given year for leap year.
  *
  * @param  integer|Zend_Date  $year  Year to check
  * @return boolean
  */
 public static function checkLeapYear($year)
 {
     if ($year instanceof Zend_Date) {
         $year = (int) $year->get(Zend_Date::YEAR);
     }
     if (!is_numeric($year)) {
         throw new Zend_Date_Exception("year ({$year}) has to be integer for isLeapYear()", $year);
     }
     return (bool) parent::isYearLeapYear($year);
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:16,代码来源:Date.php


注:本文中的Zend_Date_DateObject类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。