本文整理汇总了PHP中Zend_Date::compareMonth方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Date::compareMonth方法的具体用法?PHP Zend_Date::compareMonth怎么用?PHP Zend_Date::compareMonth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Date
的用法示例。
在下文中一共展示了Zend_Date::compareMonth方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getIntervals
public function getIntervals()
{
if (!$this->_intervals) {
$this->_intervals = array();
if (!$this->_from && !$this->_to) {
return $this->_intervals;
}
$dateStart = new Zend_Date($this->_from);
$dateEnd = new Zend_Date($this->_to);
$t = array();
$firstInterval = true;
/** START AITOC FIX **/
if (in_array((string) $this->_period, array('day', 'month', 'year'))) {
/** END AITOC FIX **/
while ($dateStart->compare($dateEnd) <= 0) {
switch ($this->_period) {
case 'day':
$t['title'] = $dateStart->toString(Mage::app()->getLocale()->getDateFormat());
$t['start'] = $dateStart->toString('yyyy-MM-dd HH:mm:ss');
$t['end'] = $dateStart->toString('yyyy-MM-dd 23:59:59');
$dateStart->addDay(1);
break;
case 'month':
$t['title'] = $dateStart->toString('MM/yyyy');
$t['start'] = $firstInterval ? $dateStart->toString('yyyy-MM-dd 00:00:00') : $dateStart->toString('yyyy-MM-01 00:00:00');
$lastInterval = $dateStart->compareMonth($dateEnd->getMonth()) == 0;
$t['end'] = $lastInterval ? $dateStart->setDay($dateEnd->getDay())->toString('yyyy-MM-dd 23:59:59') : $dateStart->toString('yyyy-MM-' . date('t', $dateStart->getTimestamp()) . ' 23:59:59');
$dateStart->addMonth(1);
if ($dateStart->compareMonth($dateEnd->getMonth()) == 0) {
$dateStart->setDay(1);
}
$firstInterval = false;
break;
case 'year':
$t['title'] = $dateStart->toString('yyyy');
$t['start'] = $firstInterval ? $dateStart->toString('yyyy-MM-dd 00:00:00') : $dateStart->toString('yyyy-01-01 00:00:00');
$lastInterval = $dateStart->compareYear($dateEnd->getYear()) == 0;
$t['end'] = $lastInterval ? $dateStart->setMonth($dateEnd->getMonth())->setDay($dateEnd->getDay())->toString('yyyy-MM-dd 23:59:59') : $dateStart->toString('yyyy-12-31 23:59:59');
$dateStart->addYear(1);
if ($dateStart->compareYear($dateEnd->getYear()) == 0) {
$dateStart->setMonth(1)->setDay(1);
}
$firstInterval = false;
break;
}
$this->_intervals[$t['title']] = $t;
}
/** START AITOC FIX **/
}
/** END AITOC FIX **/
}
return $this->_intervals;
}
示例2: testLoose
//.........这里部分代码省略.........
// success
}
try {
$date->subYear(null);
$this->fail();
} catch (Zend_Date_Exception $e) {
// success
}
try {
$date->compareYear(null);
$this->fail();
} catch (Zend_Date_Exception $e) {
// success
}
try {
$date->setMonth(null);
$this->fail();
} catch (Zend_Date_Exception $e) {
// success
}
try {
$date->addMonth(null);
$this->fail();
} catch (Zend_Date_Exception $e) {
// success
}
try {
$date->subMonth(null);
$this->fail();
} catch (Zend_Date_Exception $e) {
// success
}
try {
$date->compareMonth(null);
$this->fail();
} catch (Zend_Date_Exception $e) {
// success
}
try {
$date->setDay(null);
$this->fail();
} catch (Zend_Date_Exception $e) {
// success
}
try {
$date->addDay(null);
$this->fail();
} catch (Zend_Date_Exception $e) {
// success
}
try {
$date->subDay(null);
$this->fail();
} catch (Zend_Date_Exception $e) {
// success
}
try {
$date->compareDay(null);
$this->fail();
} catch (Zend_Date_Exception $e) {
// success
}
try {
$date->setWeekday(null);
$this->fail();
} catch (Zend_Date_Exception $e) {
示例3: _getMonthInterval
/**
* Get interval for a month
*
* @param Zend_Date $dateStart
* @param Zend_Date $dateEnd
* @param bool $firstInterval
* @return array
*/
protected function _getMonthInterval(Zend_Date $dateStart, Zend_Date $dateEnd, $firstInterval)
{
$interval = array();
$interval['period'] = $dateStart->toString('MM/yyyy');
$interval['start'] = $firstInterval ? $dateStart->toString('yyyy-MM-dd 00:00:00') : $dateStart->toString('yyyy-MM-01 00:00:00');
$lastInterval = $dateStart->compareMonth($dateEnd->getMonth()) == 0;
$interval['end'] = $lastInterval ? $dateStart->setDay($dateEnd->getDay())->toString('yyyy-MM-dd 23:59:59') : $dateStart->toString('yyyy-MM-' . date('t', $dateStart->getTimestamp()) . ' 23:59:59');
$dateStart->addMonth(1);
if ($dateStart->compareMonth($dateEnd->getMonth()) == 0) {
$dateStart->setDay(1);
}
return $interval;
}