本文整理汇总了PHP中Zend_Date::compareDate方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Date::compareDate方法的具体用法?PHP Zend_Date::compareDate怎么用?PHP Zend_Date::compareDate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Date
的用法示例。
在下文中一共展示了Zend_Date::compareDate方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isValid
public function isValid($value, $context = null)
{
$value = (string) $value;
$this->_setValue($value);
$date = new Zend_Date($value);
$startDate = new Zend_Date($this->_startDate);
if ($date->compareDate($startDate) != 0) {
$this->_error(self::INVALID);
return false;
}
return true;
}
示例2: data
function data($timestamp, $format = Zend_Date::DATE_LONG, $idioma = 'pt_BR')
{
$date = new Zend_Date($timestamp, $idioma);
if ($format == "ESPECIAL") {
if (!$date->compareDate(date("d-m-Y"))) {
return "Hoje, " . $date->get(Zend_Date::TIME_SHORT);
} else {
return date("d/m", $date->get()) . " - " . $date->get(Zend_Date::TIME_SHORT);
}
}
return $date->get($format);
}
示例3: addSpecialXmlCallback
/**
* Preparing data and adding to rss object
*
* @param array $args
*/
public function addSpecialXmlCallback($args)
{
if (!isset(self::$_currentDate)) {
self::$_currentDate = new Zend_Date();
}
// dispatch event to determine whether the product will eventually get to the result
$product = new Varien_Object(array('allowed_in_rss' => true, 'allowed_price_in_rss' => true));
$args['product'] = $product;
Mage::dispatchEvent('rss_catalog_special_xml_callback', $args);
if (!$product->getAllowedInRss()) {
return;
}
// add row to result and determine whether special price is active (less or equal to the final price)
$row = $args['row'];
$row['use_special'] = false;
$row['allowed_price_in_rss'] = $product->getAllowedPriceInRss();
if (isset($row['special_to_date']) && $row['final_price'] <= $row['special_price'] && $row['allowed_price_in_rss']) {
$compareDate = self::$_currentDate->compareDate($row['special_to_date'], Varien_Date::DATE_INTERNAL_FORMAT);
if (-1 === $compareDate || 0 === $compareDate) {
$row['use_special'] = true;
}
}
$args['results'][] = $row;
}
示例4: fetchSumGroup
/**
* 取得InfoServer数据表中某个时间段的分组数据总数
*
* @param integer $startTimestamp
* @param integer $range
* @param array|string $spec
* @return array|null
*/
public function fetchSumGroup($startTimestamp = null, $range = null, $spec = 'rTimestamp')
{
$startDate = new Zend_Date($startTimestamp);
if (empty($range)) {
$endDate = Zend_Date::now();
} else {
$endDate = clone $startDate;
$endDate->addMinute($range);
}
$unionParts = array();
for (; 0 >= ($compare = $startDate->compareDate($endDate)); $startDate->addDay(1)) {
$infoserver = clone $this;
$infoserver->setTablename($startDate);
$unionParts[] = $infoserver->getSumGroupSelect($startTimestamp, 0 == $compare ? $range : null, $spec);
}
$select = $this->getAdapter()->select()->union($unionParts, Zend_Db_Select::SQL_UNION_ALL);
return $select->query()->fetchAll(Zend_Db::FETCH_NUM);
}
示例5: testLoose
/**
* test looseBehaviour
*/
public function testLoose()
{
$date = new Zend_Date(0, 'de_DE');
try {
$date->set(null, Zend_Date::YEAR);
$this->fail();
} catch (Zend_Date_Exception $e) {
// success
}
$date->set(10, 'de_DE');
$this->assertEquals(10, $date->getTimestamp());
try {
$date->add(null, Zend_Date::YEAR);
$this->fail();
} catch (Zend_Date_Exception $e) {
// success
}
$date->add(10, 'de_DE');
$this->assertEquals(20, $date->getTimestamp());
try {
$date->sub(null, Zend_Date::YEAR);
$this->fail();
} catch (Zend_Date_Exception $e) {
// success
}
$date->sub(10, 'de_DE');
$this->assertEquals(10, $date->getTimestamp());
try {
$date->compare(null, Zend_Date::YEAR);
$this->fail();
} catch (Zend_Date_Exception $e) {
// success
}
try {
$date->equals(null, Zend_Date::YEAR);
$this->fail();
} catch (Zend_Date_Exception $e) {
// success
}
try {
$date->isEarlier(null, Zend_Date::YEAR);
$this->fail();
} catch (Zend_Date_Exception $e) {
// success
}
try {
$date->isLater(null, Zend_Date::YEAR);
$this->fail();
} catch (Zend_Date_Exception $e) {
// success
}
try {
$date->setTime(null);
$this->fail();
} catch (Zend_Date_Exception $e) {
// success
}
try {
$date->addTime(null);
$this->fail();
} catch (Zend_Date_Exception $e) {
// success
}
try {
$date->subTime(null);
$this->fail();
} catch (Zend_Date_Exception $e) {
// success
}
try {
$date->compareTime(null);
$this->fail();
} catch (Zend_Date_Exception $e) {
// success
}
try {
$date->setDate(null);
$this->fail();
} catch (Zend_Date_Exception $e) {
// success
}
try {
$date->addDate(null);
$this->fail();
} catch (Zend_Date_Exception $e) {
// success
}
try {
$date->subDate(null);
$this->fail();
} catch (Zend_Date_Exception $e) {
// success
}
try {
$date->compareDate(null);
$this->fail();
} catch (Zend_Date_Exception $e) {
//.........这里部分代码省略.........
示例6: testCompareDate
/**
* Test for compareDate
*/
public function testCompareDate()
{
$locale = new Zend_Locale('de_AT');
$date = new Zend_Date(1234567890, $locale);
$d2 = new Zend_Date(1234567899, $locale);
$date = new Zend_Date(1234567890, $locale);
$this->assertSame($date->compareDate('10.01.2009'), 1);
$this->assertSame($date->compareDate('14.02.2009'), 0);
$this->assertSame($date->compareDate('15.02.2009'), -1);
$this->assertSame($date->compareDate($d2), 0);
}