本文整理汇总了PHP中Zend_Date::addMonth方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Date::addMonth方法的具体用法?PHP Zend_Date::addMonth怎么用?PHP Zend_Date::addMonth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Date
的用法示例。
在下文中一共展示了Zend_Date::addMonth方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save
public function save(Default_Model_Pastebin $pastebin)
{
$shortId = $pastebin->getShortId();
if (empty($shortId)) {
$shortId = $this->_getShortId();
$pastebin->setShortId($shortId);
}
$name = $pastebin->getName();
$expiresTime = $pastebin->getExpires();
$expires = null;
if ($expiresTime != 'never') {
$expires = new Zend_Date();
if ($expiresTime == 'hour') {
$expires->addHour(1);
}
if ($expiresTime == 'day') {
$expires->addDay(1);
}
if ($expiresTime == 'week') {
$expires->addWeek(1);
}
if ($expiresTime == 'month') {
$expires->addMonth(1);
}
$expires = $expires->get('yyyy-MM-dd HH:mm:ss');
}
$data = array('short_id' => $shortId, 'name' => !empty($name) ? $name : 'Anonymous', 'code' => $pastebin->getCode(), 'language' => $pastebin->getLanguage(), 'expires' => $expires, 'ip_address' => $_SERVER['REMOTE_ADDR'], 'created' => date('Y-m-d H:i:s'));
if (null === ($id = $pastebin->getId())) {
unset($data['id']);
$this->getDbTable()->insert($data);
} else {
$this->getDbTable()->update($data, array('id = ?' => $id));
}
return $shortId;
}
示例2: filterByActiveState
/**
* Apply filter by card active state (based on last usage date)
*
* @return CLS_Paypal_Model_Resource_Customerstored_Collection
*/
public function filterByActiveState()
{
$now = new Zend_Date(null);
$now->addMonth(0 - CLS_Paypal_Model_Paypal_Config::STORED_CARD_TTL_MONTHS);
$this->getSelect()->where('date >= ?', Varien_Date::formatDate($now, false));
return $this;
}
示例3: testGetEntryIsEqualToPutEntry
public function testGetEntryIsEqualToPutEntry()
{
$this->_entryMapper->postEntry($this->_testEntry);
$now = new Zend_Date();
$now->addMonth(1);
$entry = $this->_entryMapper->getEntry($this->_testEntry->getId());
$entry->setTitle('Updated Test Entry')->setContent('Updated Test entry with' . PHP_EOL . 'multiple lines.')->setSummary('Updated Test entry summary.')->setUpdated($now);
$this->_entryMapper->putEntry($entry);
$this->assertTrue($entry->isEqualTo($this->_entryMapper->getEntry($entry->getId())));
}
示例4: saveAction
public function saveAction()
{
$this->_isAllowed();
if ($data = $this->getRequest()->getPost()) {
$dateFormatIso = Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
$localeCode = Mage::app()->getLocale()->getLocaleCode();
if (empty($data['date_from'])) {
$from = new Zend_Date();
} else {
$from = new Zend_Date($data['date_from'], $dateFormatIso, $localeCode);
}
$data['date_from'] = $from->setTimezone('utc')->toString(Varien_Date::DATE_INTERNAL_FORMAT);
if (empty($data['date_to'])) {
$to = new Zend_Date();
$to->addMonth(1);
} else {
$to = new Zend_Date($data['date_to'], $dateFormatIso, $localeCode);
}
$data['date_to'] = $to->setTimezone('utc')->toString(Varien_Date::DATE_INTERNAL_FORMAT);
if (!isset($data['store_view'])) {
$data['store_view'][] = '0';
}
if ($data['store_view'][0] == '0') {
$stores = Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(false, true);
foreach ($stores as $store) {
if (is_array($store['value'])) {
foreach ($store['value'] as $value) {
$data['store_view'][] = $value['value'];
}
}
}
}
$model = Mage::getModel('promotional/promotional');
$model->setData($data)->setId($this->getRequest()->getParam('id'));
try {
$model->save();
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('promotional')->__('Popup was successfully saved'));
Mage::getSingleton('adminhtml/session')->setFormData(false);
if ($this->getRequest()->getParam('back')) {
$this->_redirect('*/*/edit', array('id' => $model->getId()));
return;
}
$this->_redirect('*/*/');
return;
} catch (Exception $e) {
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
Mage::getSingleton('adminhtml/session')->setFormData($data);
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
return;
}
}
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('promotional')->__('Unable to find Popup to save'));
$this->_redirect('*/*/');
}
示例5: 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;
}
示例6: monthAction
public function monthAction()
{
// param handling
$year = $this->_getParam('year');
$month = $this->_getParam('month');
if (!$year or !$month) {
throw new Exception('');
}
// start & stop date
$startDate = new Zend_Date($year . '-' . $month . '-01', 'yyyy-M-dd');
$stopDate = new Zend_Date($startDate);
$stopDate->addMonth(1)->addDay(-1);
// spacings (start & end)
$startSpace = $startDate->get(Zend_Date::WEEKDAY_8601) - 1;
$stopSpace = 7 - $stopDate->get(Zend_Date::WEEKDAY_8601);
// arrays
$calendar = array();
$week = array();
for ($startSpace; $startSpace >= 1; $startSpace--) {
$spaceDate = new Zend_Date($startDate);
$spaceDate->addDay(-$startSpace);
$day = array('date' => $spaceDate);
$week[] = $day;
}
for ($currentDay = 1; $currentDay <= $stopDate->get('d'); $currentDay++) {
$currentDate = new Zend_Date($startDate);
$currentDate->setDay($currentDay);
$day = array('date' => $currentDate);
$week[] = $day;
if (count($week) / 7 == 1) {
$calendar[] = array('info' => $currentDate, 'columns' => $week);
$week = array();
}
}
for ($stopSpace; $stopSpace >= 1; $stopSpace--) {
$spaceDate = new Zend_Date($stopDate);
$spaceDate->addDay(-$stopSpace);
$day = array('date' => $spaceDate);
$week[] = $day;
if (count($week) / 7 == 1) {
$calendar[] = array('info' => $currentDate, 'columns' => $week);
$week = array();
}
}
// view
$this->view->rows = $calendar;
}
示例7: getIntervals
public function getIntervals()
{
if (!$this->_intervals) {
$this->_intervals = array();
if (!$this->_from && !$this->_to) {
return $this->_intervals;
}
$dateStart = new Zend_Date($this->_from);
$dateStart2 = new Zend_Date($this->_from);
$dateEnd = new Zend_Date($this->_to);
$t = array();
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'] = $dateStart->toString('yyyy-MM-01 00:00:00');
$t['end'] = $dateStart->toString('yyyy-MM-' . date('t', $dateStart->getTimestamp()) . ' 23:59:59');
$dateStart->addMonth(1);
break;
case 'year':
$t['title'] = $dateStart->toString('yyyy');
$t['start'] = $dateStart->toString('yyyy-01-01 00:00:00');
$t['end'] = $dateStart->toString('yyyy-12-31 23:59:59');
$dateStart->addYear(1);
break;
}
$this->_intervals[$t['title']] = $t;
}
if ($this->_period != 'day') {
$titles = array_keys($this->_intervals);
if (count($titles) > 0) {
$this->_intervals[$titles[0]]['start'] = $dateStart2->toString('yyyy-MM-dd 00:00:00');
$this->_intervals[$titles[count($titles) - 1]]['end'] = $dateEnd->toString('yyyy-MM-dd 23:59:59');
}
}
}
return $this->_intervals;
}
示例8: getIntervals
/**
* Retrieve array of intervals
*
* @param string $from
* @param string $to
* @param string $period
* @return array
*/
public function getIntervals($from, $to, $period = self::REPORT_PERIOD_TYPE_DAY)
{
$intervals = array();
if (!$from && !$to) {
return $intervals;
}
$start = new Zend_Date($from, Varien_Date::DATE_INTERNAL_FORMAT);
if ($period == self::REPORT_PERIOD_TYPE_DAY) {
$dateStart = $start;
}
if ($period == self::REPORT_PERIOD_TYPE_MONTH) {
$dateStart = new Zend_Date(date("Y-m", $start->getTimestamp()), Varien_Date::DATE_INTERNAL_FORMAT);
}
if ($period == self::REPORT_PERIOD_TYPE_YEAR) {
$dateStart = new Zend_Date(date("Y", $start->getTimestamp()), Varien_Date::DATE_INTERNAL_FORMAT);
}
$dateEnd = new Zend_Date($to, Varien_Date::DATE_INTERNAL_FORMAT);
while ($dateStart->compare($dateEnd) <= 0) {
switch ($period) {
case self::REPORT_PERIOD_TYPE_DAY:
$t = $dateStart->toString('yyyy-MM-dd');
$dateStart->addDay(1);
break;
case self::REPORT_PERIOD_TYPE_MONTH:
$t = $dateStart->toString('yyyy-MM');
$dateStart->addMonth(1);
break;
case self::REPORT_PERIOD_TYPE_YEAR:
$t = $dateStart->toString('yyyy');
$dateStart->addYear(1);
break;
}
$intervals[] = $t;
}
return $intervals;
}
示例9: getIntervals
/**
* Overrides standard getIntervals
* @return array
*/
public function getIntervals()
{
if (!$this->_intervals) {
$this->_intervals = array();
if (!$this->_from && !$this->_to) {
return $this->_intervals;
}
$t = array();
$diff = 0;
if ($this->_period == 'week') {
$firstWeekDay = Mage::getStoreConfig('general/locale/firstday');
$dateStart = new Zend_Date($this->_from);
$curWeekDay = $dateStart->toString('e');
if ($curWeekDay > $firstWeekDay) {
$firstWeekDay += 7;
}
$diff = abs($curWeekDay - $firstWeekDay);
}
if ($this->_period == 'week' && $diff > 0) {
$dateStart = new Zend_Date($this->_from);
$dateStart2 = new Zend_Date($this->_from);
$dateStart2->addDay($diff);
$t['title'] = $dateStart->toString(Mage::app()->getLocale()->getDateFormat());
$t['start'] = $dateStart->toString('yyyy-MM-dd 00:00:00');
$dateStart->addDay($diff)->subDay(1);
$t['title'] .= ' - ' . $dateStart->toString(Mage::app()->getLocale()->getDateFormat());
$t['end'] = $dateStart->toString('yyyy-MM-dd 23:59:59');
$dateStart->addDay(1);
if (isset($t['title'])) {
$this->_intervals[$t['title']] = $t;
}
$dateStart2 = new Zend_Date($this->_from);
$dateEnd = new Zend_Date($this->_to);
} else {
$dateStart = new Zend_Date($this->_from);
$dateStart2 = new Zend_Date($this->_from);
$dateEnd = new Zend_Date($this->_to);
}
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 'week':
$t['title'] = $dateStart->toString(Mage::app()->getLocale()->getDateFormat());
$t['start'] = $dateStart->toString('yyyy-MM-dd 00:00:00');
$dateStart->addWeek(1)->subDay(1);
$t['title'] .= ' - ' . $dateStart->toString(Mage::app()->getLocale()->getDateFormat());
$t['end'] = $dateStart->toString('yyyy-MM-dd 23:59:59');
$dateStart->addDay(1);
break;
case 'month':
$t['title'] = $dateStart->toString('MM/yyyy');
$t['start'] = $dateStart->toString('yyyy-MM-01 00:00:00');
$t['end'] = $dateStart->toString('yyyy-MM-' . date('t', $dateStart->getTimestamp()) . ' 23:59:59');
$dateStart->addMonth(1);
break;
case 'quarter':
$month = (int) $dateStart->toString('MM');
$num = round($month / 3) + 1;
$t['title'] = Mage::helper('advancedreports')->__('Q') . $num . $dateStart->toString('/yyyy');
$t['start'] = $dateStart->toString('yyyy-MM-01 00:00:00');
$dateStart->addMonth(2);
$t['end'] = $dateStart->toString('yyyy-MM-' . date('t', $dateStart->getTimestamp()) . ' 23:59:59');
$dateStart->addMonth(1);
break;
case 'year':
$t['title'] = $dateStart->toString('yyyy');
$t['start'] = $dateStart->toString('yyyy-01-01 00:00:00');
$t['end'] = $dateStart->toString('yyyy-12-31 23:59:59');
$dateStart->addYear(1);
break;
default:
Mage::throwException("Report tried to get intervals without a period.");
}
if (isset($t['title'])) {
$this->_intervals[$t['title']] = $t;
}
// echo $t['start'].' - '.$t['end'].'<hr>';
}
if ($this->_period != 'day') {
$titles = array_keys($this->_intervals);
if (count($titles) > 0) {
$this->_intervals[$titles[0]]['start'] = $dateStart2->toString('yyyy-MM-dd 00:00:00');
$this->_intervals[$titles[count($titles) - 1]]['end'] = $dateEnd->toString('yyyy-MM-dd 23:59:59');
if ($this->_period == 'week') {
$t = $this->_intervals[$titles[count($titles) - 1]];
unset($this->_intervals[$titles[count($titles) - 1]]);
$date = new Zend_Date($t['start'], 'yyyy-MM-dd 00:00:00');
$t['title'] = $date->toString(Mage::app()->getLocale()->getDateFormat());
unset($date);
$date = new Zend_Date($t['end'], 'yyyy-MM-dd 23:59:59');
$t['title'] .= ' - ' . $date->toString(Mage::app()->getLocale()->getDateFormat());
//.........这里部分代码省略.........
示例10: testGmtOffsetValues
/**
* Test for False Month Addition
*/
public function testGmtOffsetValues()
{
date_default_timezone_set('Pacific/Auckland');
$time = time();
$date = new Zend_Date($time);
$stamp = $date->getGmtOffset();
$localtime = localtime($time, true);
$offset = mktime($localtime['tm_hour'], $localtime['tm_min'], $localtime['tm_sec'], $localtime['tm_mon'] + 1, $localtime['tm_mday'], $localtime['tm_year'] + 1900) - gmmktime($localtime['tm_hour'], $localtime['tm_min'], $localtime['tm_sec'], $localtime['tm_mon'] + 1, $localtime['tm_mday'], $localtime['tm_year'] + 1900);
$this->assertEquals($stamp, $offset);
$date->addMonth(6);
$stamp = $date->getGmtOffset();
$localtime = localtime($time, true);
$offset = mktime($localtime['tm_hour'], $localtime['tm_min'], $localtime['tm_sec'], $localtime['tm_mon'] + 7, $localtime['tm_mday'], $localtime['tm_year'] + 1900) - gmmktime($localtime['tm_hour'], $localtime['tm_min'], $localtime['tm_sec'], $localtime['tm_mon'] + 7, $localtime['tm_mday'], $localtime['tm_year'] + 1900);
$this->assertEquals($stamp, $offset);
}
示例11: _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;
}
示例12: successAction
public function successAction()
{
try {
// $userWalletMapper = new Application_Model_UserWalletMapper();
// $userWallet = new Application_Model_UserWallet();
// $userPackagesMapper = new Application_Model_UserPackagesMapper();
// $userPackages = new Application_Model_UserPackages();
$userTrackMapper = new Application_Model_UserTrackMapper();
$userTrack = new Application_Model_UserTrack();
$ordersMapper = new Application_Model_OrdersMapper();
// $packagesMapper = new Application_Model_PackagesMapper();
$userTransactionsMapper = new Application_Model_UserTransactionsMapper();
$userTransactions = new Application_Model_UserTransactions();
$request = $this->getRequest();
$status = $request->getParam("status");
$fname = $request->getParam("firstname");
$amount = $request->getParam("amount");
$txnid = $request->getParam("txnid");
$posted_hash = $request->getParam("hash");
$product_info = $request->getParam("productinfo");
$key = $request->getParam("key");
$email = $request->getParam("email");
$code = $request->getParam("bankcode");
$salt = "dwf1Ltip";
//test salt
$salt = "GQs7yium";
$retHashSeq = $salt . '|' . $status . '|||||||||||' . $email . '|' . $fname . '|' . $product_info . '|' . $amount . '|' . $txnid . '|' . $key;
$hash = hash("sha512", $retHashSeq);
$infos = explode("|", $product_info);
$transaction_type = explode(":", $infos[0]);
$transaction_type = $transaction_type[1];
//echo $transaction_type;exit;
$user_id = explode(":", $infos[1]);
$user_id = $user_id[1];
$id = explode(":", $infos[2]);
$id = $id[1];
$package_id = explode(":", $infos[3]);
$package_id = $package_id[1];
if ($user_id != 0) {
$userTransactions->__set("trnx_user_id", $user_id);
$userTransactions->__set("other_details", $transaction_type);
$userTransactions->__set("gateway_transaction_id", $txnid);
$userTransactions->__set("trnx_amount", $amount);
$userTransactions->__set("trnx_method", $code);
$userTransactions->__set("trnx_status", $status);
$userTransactions->__set("trnx_order_id", $id);
$userTransactionsMapper->addNewUserTransaction($userTransactions);
}
if ($hash != $posted_hash) {
throw new Exception("Invalid Transaction");
} else {
$flag = TRUE;
$this->view->flag = $flag;
if ($transaction_type == "Package") {
//echo "in";
$package = $packagesMapper->getPackageById($package_id);
$number_clothes = $package->__get("no_of_clothes");
$number_pickups = $package->__get("no_of_pickups");
//echo $number_pickups;exit;
$validity = $package->__get("validity");
//echo $validity;exit;
$zend_date = new Zend_Date();
$date = $zend_date->addMonth($validity);
$new_date = $date->toString("dd-MM-yyyy");
$userTrack->__set("usertrack_user_id", $user_id);
$userTrack->__set("track_type", 'package');
$userTrack->__set("usertrack_package_id", $package_id);
$userTrack->__set("clothes_left", $number_clothes);
$userTrack->__set("clothes_availed", $number_clothes);
$userTrack->__set("pickups_left", $number_pickups);
$userTrack->__set("pickups_availed", $number_pickups);
$userTrack->__set("usertrack_start_date", date('Y-m-d'));
$userTrack->__set("usertrack_expiry_date", $new_date);
if ($userTrackMapper->addNewTrack(addNewTrack)) {
$this->view->hasMessage = true;
$this->view->messageType = "success";
$this->view->message = "Profile Updated successfully";
} else {
$this->view->hasMessage = true;
$this->view->messageType = "danger";
$this->view->message = "Error while updating";
}
} elseif ($transaction_type == "Online") {
$order = $ordersMapper->getOrderById($id);
$order->__set("order_payment_status", "Paid");
$ordersMapper->updateOrder($order);
}
$this->_redirect('index/orderlist');
}
} catch (Exception $e) {
$e->getMessage();
}
}
示例13: testLoose
//.........这里部分代码省略.........
// success
}
try {
$date->setYear(null);
$this->fail();
} catch (Zend_Date_Exception $e) {
// success
}
try {
$date->addYear(null);
$this->fail();
} catch (Zend_Date_Exception $e) {
// 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) {
示例14: getIntervals
/**
* Overrides standard getIntervals
* @return array
*/
public function getIntervals()
{
if (!$this->_intervals) {
$this->_intervals = array();
if (!$this->_from && !$this->_to) {
return $this->_intervals;
}
$dateStart = new Zend_Date($this->_from);
$dateStart2 = new Zend_Date($this->_from);
$dateEnd = new Zend_Date($this->_to);
$t = array();
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 'week':
$t['title'] = $dateStart->toString(Mage::app()->getLocale()->getDateFormat());
$t['start'] = $dateStart->toString('yyyy-MM-dd 00:00:00');
$dateStart->addWeek(1)->subDay(1);
$t['title'] .= ' - ' . $dateStart->toString(Mage::app()->getLocale()->getDateFormat());
$t['end'] = $dateStart->toString('yyyy-MM-dd 23:59:59');
$dateStart->addDay(1);
break;
case 'month':
$t['title'] = $dateStart->toString('MM/yyyy');
$t['start'] = $dateStart->toString('yyyy-MM-01 00:00:00');
$t['end'] = $dateStart->toString('yyyy-MM-' . date('t', $dateStart->getTimestamp()) . ' 23:59:59');
$dateStart->addMonth(1);
break;
case 'quarter':
$month = (int) $dateStart->toString('MM');
$num = round($month / 3) + 1;
$t['title'] = Mage::helper('advancedreports')->__('Q') . $num . $dateStart->toString('/yyyy');
$t['start'] = $dateStart->toString('yyyy-MM-01 00:00:00');
$dateStart->addMonth(2);
$t['end'] = $dateStart->toString('yyyy-MM-' . date('t', $dateStart->getTimestamp()) . ' 23:59:59');
$dateStart->addMonth(1);
break;
case 'year':
$t['title'] = $dateStart->toString('yyyy');
$t['start'] = $dateStart->toString('yyyy-01-01 00:00:00');
$t['end'] = $dateStart->toString('yyyy-12-31 23:59:59');
$dateStart->addYear(1);
break;
}
$this->_intervals[$t['title']] = $t;
// echo $t['start'].' - '.$t['end'].'<hr>';
}
if ($this->_period != 'day') {
$titles = array_keys($this->_intervals);
if (count($titles) > 0) {
$this->_intervals[$titles[0]]['start'] = $dateStart2->toString('yyyy-MM-dd 00:00:00');
$this->_intervals[$titles[count($titles) - 1]]['end'] = $dateEnd->toString('yyyy-MM-dd 23:59:59');
if ($this->_period == 'week') {
$t = $this->_intervals[$titles[count($titles) - 1]];
unset($this->_intervals[$titles[count($titles) - 1]]);
$date = new Zend_Date($t['start']);
$t['title'] = $date->toString(Mage::app()->getLocale()->getDateFormat());
unset($date);
$date = new Zend_Date($t['end']);
$t['title'] .= ' - ' . $date->toString(Mage::app()->getLocale()->getDateFormat());
$this->_intervals[$t['title']] = $t;
}
}
}
}
return $this->_intervals;
}
示例15: chartSentDay
/**
*
* @param array $filters
* @return array
*/
public function chartSentDay(array $filters = array())
{
$date = new Zend_Date();
// Set the date to search the current month
$filters['date_ini'] = $date->setDay(1)->toString('yyyy-MM-dd');
$filters['date_fin'] = $date->addMonth(1)->subDay(1)->toString('yyyy-MM-dd');
// Search just the sending successfully
$filters['status'] = 'S';
$sent = $this->sentByDays($filters);
// Search the erros with errors
$filters['status'] = 'E';
$errors = $this->sentByDays($filters);
$months = array();
foreach ($sent as $row) {
$months[] = $row->day;
}
foreach ($errors as $row) {
$months[] = $row->day;
}
$months = array_fill_keys(array_unique($months), array('errors' => 0, 'sent' => 0));
foreach ($sent as $row) {
$months[$row->day]['sent'] = $row->sent;
}
foreach ($errors as $row) {
$months[$row->day]['errors'] = $row->sent;
}
$data = array('months' => array_keys($months), 'errors' => array(), 'sent' => array());
foreach ($months as $row) {
$data['errors'][] = (int) $row['errors'];
$data['sent'][] = (int) $row['sent'];
}
return $data;
}