Esempio n. 1
0
	/**
	 * Initialization.
	 * @see PHPUnit_Framework_TestCase::setUp()
	 */
	protected function setUp() {
		$this->requested_at = new Zend_Date();
		$this->received_at = new Zend_Date();
		$this->received_at->addDay(14)->addHour(1)->addMinute(15);

		$this->history = new Blipoteka_Book_History();
		$this->history->borrower_id = 1;
		$this->history->lender_id = 2;
		$this->history->book_id = 1;
		$this->history->requested_at = $this->requested_at->get(Zend_Date::W3C);
		$this->history->received_at = $this->received_at->get(Zend_Date::W3C);
	}
 public function indexAction()
 {
     // numero da semana anterior
     $zendDate = new Zend_Date();
     $semana = $zendDate->get(Zend_Date::WEEK) - 1;
     $dia_semana = $zendDate->get(Zend_Date::WEEKDAY_DIGIT);
     $zendDate->subDay(7);
     $dia_semana_inicio = $dia_semana - 1;
     $dia_semana_fim = 7 - $dia_semana;
     $periodo_inicial = $zendDate->subDay($dia_semana_inicio)->get("dd/MM/YYYY");
     $periodo_final = $zendDate->addDay($dia_semana_fim)->get('dd/MM/YYYY');
     $periodo = $periodo_inicial . ' à ' . $periodo_final;
     // busca as visualizacoes da semana
     $modelSalaoVisualizacao = new Model_DbTable_SalaoVisualizacao();
     $visualizacoes = $modelSalaoVisualizacao->visualizacoes($semana);
     try {
         foreach ($visualizacoes as $visualizacao) {
             $pluginMail = new Plugin_Mail();
             $pluginMail->setDataMail('visualizacao', $visualizacao);
             $pluginMail->setDataMail('periodo', $periodo);
             $pluginMail->send("salao-visualizacao.phtml", "Relatório de Visualizações", $visualizacao->salao_email);
         }
         echo 'emails enviados';
     } catch (Zend_Mail_Exception $ex) {
         die('email');
     } catch (Exception $ex) {
         Zend_Debug::dump($ex->getMessage());
     }
 }
Esempio n. 3
0
 /**
  * Create multiple trips. We can call it scheduling the bus board. 
  * @param int $routeID
  * @param int $tripCount
  * @param int $dayCount
  * @param string $startDate
  * @param array $tripLines
  */
 public function createMultipleTrips($routeID, $tripCount, $dayCount, $startDate, $tripLines = array())
 {
     if (empty($tripLines) || count($tripLines) != $tripCount) {
         throw new Exception('Something wrong');
     }
     $db = Zend_Db_Table::getDefaultAdapter();
     $db->beginTransaction();
     try {
         for ($i = 0; $i < $dayCount; ++$i) {
             foreach ($tripLines as $tripLine) {
                 $departureDatetimeObj = new Zend_Date(TBB_Utility_Date::formatDateTime($tripLine['departureTime'], 'dd-MM-y HH:mm:ss', 'y-MM-dd HH:mm:ss'));
                 $departureDatetimeObj->addDay($i);
                 $arrivalDatetimeObj = new Zend_Date(TBB_Utility_Date::formatDateTime($tripLine['arrivalTime'], 'dd-MM-y HH:mm:ss', 'y-MM-dd HH:mm:ss'));
                 $arrivalDatetimeObj->addDay($i);
                 $tripRow = $this->createRow();
                 $tripRow->route_id = $routeID;
                 $tripRow->bus_id = $tripLine['bus'];
                 $tripRow->departure_time = $departureDatetimeObj->toString('y-MM-dd HH:mm:ss');
                 $tripRow->arrival_time = $arrivalDatetimeObj->toString('y-MM-dd HH:mm:ss');
                 $tripRow->fare = $tripLine['fare'];
                 $tripRow->expired = 0;
                 $tripRow->save();
             }
         }
         $db->commit();
     } catch (Exception $e) {
         $db->rollBack();
         throw new $e();
     }
 }
Esempio n. 4
0
 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;
 }
Esempio n. 5
0
 /**
  * (non-PHPdoc)
  *
  * @see library/Oara/Network/Oara_Network_Publisher_Base#getTransactionList($merchantId, $dStartDate, $dEndDate)
  */
 public function getTransactionList($merchantList = null, Zend_Date $dStartDate = null, Zend_Date $dEndDate = null, $merchantMap = null)
 {
     $totalTransactions = array();
     $dEndDate->addDay(1);
     $valuesFormExport = Oara_Utilities::cloneArray($this->_exportTransactionParameters);
     $valuesFormExport[] = new Oara_Curl_Parameter('pDate1', $dStartDate->toString("MM/d/yyyy"));
     $valuesFormExport[] = new Oara_Curl_Parameter('pDate2', $dEndDate->toString("MM/d/yyyy"));
     $urls = array();
     $urls[] = new Oara_Curl_Request('https://www.auto-europe.co.uk/afftools/iatareport_popup.cfm?', $valuesFormExport);
     $exportReport = $this->_client->post($urls);
     $xmlTransactionList = self::readTransactions($exportReport[0]);
     foreach ($xmlTransactionList as $xmlTransaction) {
         $transaction = array();
         $transaction['merchantId'] = 1;
         $date = new Zend_date($xmlTransaction['Booked'], "MM/dd/yyyy");
         $transaction['date'] = $date->toString("yyyy-MM-dd 00:00:00");
         $transaction['amount'] = (double) $xmlTransaction['commissionValue'];
         $transaction['commission'] = (double) $xmlTransaction['commission'];
         $transaction['status'] = Oara_Utilities::STATUS_CONFIRMED;
         $transaction['unique_id'] = $xmlTransaction['Res #'];
         if (isset($xmlTransaction['Affiliate1']) && isset($xmlTransaction['Affiliate2'])) {
             $customId = (string) $xmlTransaction['Affiliate1'] . (string) $xmlTransaction['Affiliate2'];
             $customId = "afal-" . current(unpack('H*', base64_decode(str_replace(array(".", "-"), array("/", "+"), $customId))));
             $transaction['custom_id'] = $customId;
         }
         $totalTransactions[] = $transaction;
     }
     return $totalTransactions;
 }
 public function addExpiredAfterDaysFilter($daysToAdd)
 {
     $currentZendDate = new Zend_Date();
     $dateAfterDays = $currentZendDate->addDay($daysToAdd + 1)->toString(Varien_Date::DATE_INTERNAL_FORMAT);
     $this->getSelect()->where('expiration_date < ?', $dateAfterDays)->where('expiration_notification_sent IS NULL')->order('summary_id');
     return $this;
 }
 /**
  * JavaScript get-locale action
  */
 public function getLocaleAction()
 {
     $aLocale = array();
     try {
         $sFileName = APPLICATION_PATH . '/i18n/' . $this->localizer->getLocale()->getLanguage() . '.txt';
         if (!file_exists($sFileName) || !is_file($sFileName) || !is_readable($sFileName)) {
             throw new AM_Component_Exception('Localisation file not found');
         }
         $aFile = file($sFileName);
         while (list($iLineNumber, $sLine) = each($aFile)) {
             $sLine = trim($sLine);
             if (!$sLine || strlen($sLine) < 3 || substr($sLine, 0, 3) != 'js_') {
                 continue;
             }
             $aPair = explode('=', substr($sLine, 3));
             if (count($aPair) != 2 || !$aPair[0] || !$aPair[1]) {
                 continue;
             }
             $aLocale[$aPair[0]] = $aPair[1];
         }
         $oDate = new Zend_Date();
         $oDate->addDay(self::LOCALE_EXPIRES_DAYS);
         $this->getResponse()->setHeader('Content-type', 'text/javascript')->setHeader('Content-Disposition:inline', ' filename=locale.js')->setHeader('Pragma', 'public', true)->setHeader('Cache-Control', 'maxage=' . 60 * 60 * 24 * self::LOCALE_EXPIRES_DAYS, true)->setHeader('Expires', $oDate->toString('EE, d M Y H:i:s ') . 'GMT', true);
     } catch (Exception $ex) {
     }
     $this->view->locale = $aLocale;
 }
Esempio n. 8
0
 public static function createNew($rule, $startFrom = null)
 {
     $date = new Zend_Date();
     $date->addDay((int) $rule->getCouponExpireDays());
     $date->setHour(0)->setMinute(0)->setSecond(0);
     if (!is_null($startFrom)) {
         $date->addDay((int) $startFrom);
     }
     $coupon = Mage::getModel('followupemail/coupons');
     $salesRule = Mage::getModel('salesrule/rule')->load($rule->getCouponSalesRuleId());
     if ($salesRule->getData()) {
         $_usagePerCustomer = $salesRule->getUsesPerCustomer() && is_numeric($salesRule->getUsesPerCustomer()) ? $salesRule->getUsesPerCustomer() : 1;
         $coupon->setRuleId($rule->getCouponSalesRuleId())->setExpirationDate($date)->setCode(Mage::helper('followupemail/coupon')->generateCode($rule->getId(), $rule->getCouponPrefix()))->setUsagePerCustomer($_usagePerCustomer)->setUsageLimit($_usagePerCustomer);
         $coupon->save();
     }
     return $coupon;
 }
Esempio n. 9
0
 public function addExpireAfterDaysFilter($dayBefore)
 {
     $date = Mage::getModel('core/date')->gmtDate();
     $zendDate = new Zend_Date($date);
     $dayAfter = $zendDate->addDay($dayBefore)->toString('YYYY-MM-dd');
     $this->getSelect()->where('date(expired_at) = ?', $dayAfter);
     return $this;
 }
Esempio n. 10
0
 public function getExpirationDate()
 {
     if ($timeLife = Mage::helper('customerreward')->getEarnConfig('expire')) {
         //$currentDate = Mage::getModel('core/date')->gmtDate();
         $expire = new Zend_Date();
         //$currentDate);
         $expire->addDay($timeLife);
         return $expire->toString('YYYY-MM-dd HH:mm:ss');
     }
     return null;
 }
 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;
 }
Esempio n. 12
0
 public function getbookdetailsAction()
 {
     self::createModel();
     $request = $this->getRequest();
     $acc_no = $request->getParam('acc_no');
     $objIsbn = new Lib_Model_DbTable_Isbn();
     $objIssueReturn = new Lib_Model_DbTable_IssueReturn();
     $book = array();
     if (isset($acc_no)) {
         $bookInfo = Lib_Model_DbTable_Book::getBookInfo($acc_no);
         if (isset($bookInfo['isbn_id'])) {
             $book = $objIsbn->getIsbnDetails($bookInfo['isbn_id']);
             $bookIssued = $objIssueReturn->getIssuedBookInfo($acc_no);
             //$this->_helper->logger($bookIssued);
             if ($bookIssued) {
                 $issueDate = new Zend_Date($bookIssued['issue_date'], Zend_Date::ISO_8601);
                 $book['member_id'] = $bookIssued['member_id'];
                 $member_limit = Lib_Model_DbTable_MembershipLimit::getMemberLimit($book['member_id'], $bookInfo['document_type_id']);
                 if (isset($_SESSION['dateFormat'])) {
                     $dateFormat = $_SESSION['dateFormat'];
                 } else {
                     $dateFormat = 'dd/MMM/yyyy';
                 }
                 $book['issue_date'] = $issueDate->toString($dateFormat);
                 $exp_return_date = $issueDate->addDay($member_limit['day_limit']);
                 $day_late = 0;
                 $objtoday = new Zend_Date(Zend_Date::now(), $dateFormat);
                 if ($exp_return_date->isToday() || $objtoday->isEarlier($exp_return_date)) {
                     $day_late = 0;
                 } else {
                     $objtoday->sub($exp_return_date);
                     $day_late = $objtoday->get(Zend_Date::DAY) - 2;
                 }
                 $book['exp_return_date'] = $exp_return_date->toString($dateFormat);
                 $book['day_late'] = $day_late;
                 $bookStatus = 1;
             }
             $book['bookInfo'] = $bookInfo;
             $this->_helper->json($book);
             //echo Zend_Json::encode($book);
         } else {
             $this->getResponse()->setHttpResponseCode(400);
             echo 'Either the Acc No "' . $acc_no . '" or its corrosponding ISBN is invalid.';
         }
     } else {
         $this->getResponse()->setHttpResponseCode(400);
         echo 'Parameters are insufficient to process.';
     }
 }
Esempio n. 13
0
 public function addError()
 {
     if ($this->getPromotionId() and $this->getCustomerId()) {
         $now = $this->formatDate(null, 'y-MM-dd HH:mm:ss');
         $date = new Zend_Date($this->getLastError());
         $last_error = $date->addDay(1)->toString('y-MM-dd HH:mm:ss');
         if ($last_error < $now) {
             $nbr = 1;
         } else {
             $nbr = (int) $this->getNumberOfError() + 1;
         }
         $this->setNumberOfError($nbr)->setLastError($now)->save();
         return $this;
     }
 }
 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;
 }
 /**
  * Returns probably expire date
  * @return Zend_Date
  */
 public function getDateExpire()
 {
     if (!$this->getData('date_expire')) {
         if (!$this->isInfinite()) {
             foreach (Mage::getModel('sarp/sequence')->getCollection()->addSubscriptionFilter($this)->setOrder('date', 'desc') as $SequenceItem) {
                 $offset = $this->getPeriod()->getPaymentOffset();
                 $date = new Zend_Date($SequenceItem->getDate(), self::DB_DATE_FORMAT);
                 return $date->addDay($offset);
                 //return Mage::app()->getLocale()->date($SequenceItem->getDate(), self::DB_DATE_FORMAT);
             }
         } else {
             // No expiration date
             return $this->getNextSubscriptionEventDate(new Zend_Date());
         }
     }
     return new Zend_Date();
 }
Esempio n. 16
0
 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;
 }
Esempio n. 17
0
 /**
  * Processing object before save data.
  * Prepare history data
  *
  * @return Enterprise_Reward_Model_Reward_History
  */
 protected function _beforeSave()
 {
     if ($this->getWebsiteId()) {
         $this->setBaseCurrencyCode(Mage::app()->getWebsite($this->getWebsiteId())->getBaseCurrencyCode());
     }
     if ($this->getPointsDelta() < 0) {
         $this->_spendAvailablePoints($this->getPointsDelta());
     }
     $now = $this->getResource()->formatDate(time());
     $this->addData(array('created_at' => $now, 'expired_at_static' => null, 'expired_at_dynamic' => null, 'notification_sent' => 0));
     $lifetime = (int) Mage::helper('enterprise_reward')->getGeneralConfig('expiration_days', $this->getWebsiteId());
     if ($lifetime > 0) {
         $expireAt = new Zend_Date($now);
         $expireAt->addDay($lifetime);
         $expired = $this->getResource()->formatDate($expireAt);
         $this->addData(array('expired_at_static' => $expired, 'expired_at_dynamic' => $expired));
     }
     return parent::_beforeSave();
 }
Esempio n. 18
0
 public function isValid($data)
 {
     $isValid = parent::isValid($data);
     if ($isValid) {
         $date = new Zend_Date();
         $date2 = clone $date;
         $date->set($data['date_for'], 'YYYY-MM-dd');
         $date2->set($data['date_to'], 'YYYY-MM-dd');
         if ($date->getDate()->isLater($date2->getDate())) {
             $isValid = false;
             $this->getElement('date_to')->addError('Data do musi być późniejsza niż Data od');
         } else {
             $date->addDay(31);
             if ($date->getDate()->isEarlier($date2->getDate())) {
                 $isValid = false;
                 $this->getElement('date_to')->addError('Wygenerowanie raportu możliwe jest za dowolny okres obejmujący max 31 dni');
             }
         }
     }
     return $isValid;
 }
Esempio n. 19
0
 public static function getCurrentSessionHolidays()
 {
     $session_startdate = Core_Model_DbTable_AcademicSession::getSessionStartDate();
     $session_enddate = Core_Model_DbTable_AcademicSession::getSessionEndDate();
     $sql = self::getDefaultAdapter()->select()->from('holiday', array('date_from', 'date_upto', 'purpose'))->where('date_from >= ? ', $session_startdate)->where('date_from <= CURRENT_DATE() ');
     $holiday = $sql->query()->fetchAll();
     $dates = array();
     $cnt = 0;
     foreach ($holiday as $key => $value) {
         $start_date = $value['date_from'];
         $end_date = $value['date_upto'];
         $objstart = new Zend_Date($start_date, Zend_Date::ISO_8601);
         $objenddate = new Zend_Date($end_date, Zend_Date::ISO_8601);
         while (!$objstart->isLater($objenddate)) {
             $dates[$cnt++] = $objstart->get(Zend_date::YEAR) . '-' . $objstart->get(Zend_date::MONTH) . '-' . $objstart->get(Zend_date::DAY) . '-' . $value['purpose'];
             $objstart->addDay(1);
         }
         $objstart = NULL;
         $objenddate = NULL;
     }
     return $dates;
 }
Esempio n. 20
0
 /**
  * The export action
  */
 public function indexAction()
 {
     header("Content-Type: text/Calendar");
     header("Content-Disposition: inline; filename=Geburtstage.ics");
     $uid = $this->getRequest()->getParam('uid', null);
     $filter = array();
     if ($uid !== null) {
         $filter['id'] = $uid;
     }
     $userDTOs = Bc_UserDTO::fetch($filter);
     $users = array();
     foreach ($userDTOs as $userDTO) {
         $birthdate = new Zend_Date();
         $birthdate->set($userDTO->get('birthdate'), Zend_Date::ISO_8601);
         $nextdate = new Zend_Date();
         $nextdate->set($userDTO->get('birthdate'), Zend_Date::ISO_8601);
         $nextdate->addDay('1', Zend_Date::DAY);
         $users[] = array('id' => $userDTO->get('id'), 'birthYear' => $birthdate->get(Zend_Date::YEAR), 'birthDate' => $birthdate->toString('yyyyMMdd'), 'birthMonth' => $birthdate->get(Zend_Date::MONTH), 'birthDay' => $birthdate->get(Zend_Date::DAY), 'nextDate' => $nextdate->toString('yyyyMMdd'), 'firstName' => $userDTO->get('firstname'), 'secondName' => $userDTO->get('secondname'));
     }
     $this->view->users = $users;
     $this->view->timeStamp = date("Ymd") . 'T' . date("His") . 'Z';
 }
Esempio n. 21
0
 public function render(Varien_Object $row)
 {
     $html = '';
     $weekendsexclude = Mage::getStoreConfig('reminder/timesettings/weekendsexclude');
     // Obtain the order/reminder details
     $incrementid = $row->getIncrementId();
     $reminderorders = Mage::getModel('reminder/reminder')->getCollection()->addFieldToFilter('increment_id', $incrementid)->getItems();
     $reminderorder = reset($reminderorders);
     // Obtain the age
     $now = new Zend_Date(Mage::getModel('core/date')->gmtTimestamp());
     $orderdate = new Zend_Date($row->getCreatedAt(), 'yyyy-MM-dd');
     $age = $now->sub($orderdate)->toValue();
     $days = ceil($age / 60 / 60 / 24);
     // Obtain the age (weekend excluded)
     if ($weekendsexclude == 'enabled') {
         $start_date = new Zend_Date($row->getCreatedAt(), 'yyyy-MM-dd');
         $end_date = new Zend_Date($start_date);
         $dayscounter = $days;
         $weekenddays = 0;
         while ($dayscounter > 0) {
             $weekdaydigit = $end_date->toValue(Zend_Date::WEEKDAY_DIGIT);
             if ($weekdaydigit == 0 || $weekdaydigit == 6) {
                 $weekenddays++;
             }
             $end_date->addDay(1);
             $dayscounter--;
         }
         $days = $days - $weekenddays;
     }
     // Display the HTML
     $html .= $reminderorder->getReminders();
     $html .= ' (age: ' . $days . ')';
     $html .= '<br/><a href="' . $this->getUrl('*/*/manipulate/option/add/id/' . $row->getIncrementId()) . '">' . Mage::helper('reminder')->__('add') . ' 1</a>';
     $html .= '<br/><a href="' . $this->getUrl('*/*/manipulate/option/sub/id/' . $row->getIncrementId()) . '">' . Mage::helper('reminder')->__('remove') . ' 1</a>';
     $html .= '<br/><a href="' . $this->getUrl('*/*/manipulate/option/reset/id/' . $row->getIncrementId()) . '">' . Mage::helper('reminder')->__('reset to') . ' 0</a>';
     return $html;
 }
Esempio n. 22
0
 /**
  * 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;
 }
Esempio n. 23
0
 /**
  * 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;
 }
 /**
  * @loadFixture testGetProduct
  * @dataProvider provider__testCalculateCouponExpireDate
  *
  */
 public function testCalculateCouponExpireDate($dealId, $storeId, $days, $uid)
 {
     $currentDate = gmdate('Y-m-d h:i:s');
     $deal = Mage::getModel('collpur/deal')->load($dealId);
     $deal->setAvailableTo($currentDate);
     $expirationDate = $deal->calculateCouponExpireDate($dealId, $deal, $storeId, true, true);
     $currentDate = new Zend_Date($currentDate, Zend_Date::ISO_8601);
     $dateAfterStamp = $currentDate->addDay($days)->getTimestamp();
     $expected = Mage::getModel('core/locale')->storeDate($storeId, $dateAfterStamp, true)->toString(Varien_Date::DATETIME_INTERNAL_FORMAT);
     $this->assertEquals($expirationDate, $expected);
 }
Esempio n. 25
0
 /**
  * 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) {
         // success
     }
     try {
         $date->setIso(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->addIso(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->subIso(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->compareIso(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->setArpa(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->addArpa(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->subArpa(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->compareArpa(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // 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) {
         // success
     }
     try {
         $date->compareDay(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->setWeekday(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->addWeekday(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->subWeekday(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->compareWeekday(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->setDayOfYear(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->addDayOfYear(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->subDayOfYear(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->compareDayOfYear(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->setHour(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->addHour(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->subHour(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->compareHour(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->setMinute(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->addMinute(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->subMinute(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->compareMinute(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->setSecond(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->addSecond(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->subSecond(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->compareSecond(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->setWeek(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->addWeek(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->subWeek(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->compareWeek(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
 }
 public function calculadataemissaoduracaoAction()
 {
     //$data = $this->_request->getParam("dtIni");
     $tipo = $this->_request->getParam("tipo");
     $duracao = $this->_request->getParam("duracao");
     $dtEmissao = $this->_request->getParam("dtEmissao");
     if (empty($dtEmissao) && strlen($dtEmissao) < 10) {
         $result['data'] = false;
         echo json_encode($result);
         exit;
     }
     if (!empty($duracao)) {
         $objData = new Zend_Date($dtEmissao);
         $objData->addDay($duracao);
         $data = date('d/m/Y', $objData->getTimestamp());
         if (!empty($data)) {
             $result['existe'] = true;
             $result['data'] = $data;
             echo json_encode($result);
             exit;
         } else {
             $result['data'] = false;
             echo json_encode($result);
             exit;
         }
     }
     $arrDtTemp = explode("/", $dtEmissao);
     $dtTemp = $arrDtTemp[2] . $arrDtTemp[1] . $arrDtTemp[0];
     $result = array();
     if ($dtTemp > date("Ymd")) {
         $result['error'] = true;
         $result['msg'] = utf8_encode("Data de emiss&atilde;o deve ser menor ou igual a data atual");
         echo json_encode($result);
         exit;
     } else {
         if (!empty($tipo)) {
             if ($tipo == 1) {
                 $qtdDias = $this->CQTF;
             } else {
                 if ($tipo == 2) {
                     $qtdDias = $this->INSS;
                 } else {
                     $qtdDias = $this->FGTS;
                 }
             }
         }
         $dtEmissao = $arrDtTemp[0] . '-' . $arrDtTemp[1] . '-' . $arrDtTemp[2];
         $dtEmissao = date('d/m/Y', strtotime("+" . $qtdDias . " days", strtotime($dtEmissao)));
         if (!empty($dtEmissao)) {
             $result['existe'] = true;
             $result['error'] = false;
             $result['data'] = $dtEmissao;
             echo json_encode($result);
             exit;
         } else {
             $result['data'] = false;
             $result['error'] = false;
             echo json_encode($result);
             exit;
         }
     }
 }
Esempio n. 27
0
 /**
  * 取得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);
 }
Esempio n. 28
0
 /**
  * test for getWeek
  */
 public function testGetWeek()
 {
     $locale = new Zend_Locale('de_AT');
     $date = new Zend_Date(1168293600, $locale);
     //Tuesday
     $date->addDay(1);
     $this->assertSame($date->getWeek()->toString(), '08.01.1970 01:00:00');
     //Wednesday
     $date->addDay(1);
     $this->assertSame($date->getWeek()->toString(), '08.01.1970 01:00:00');
     //Thursday
     $date->addDay(1);
     $this->assertSame($date->getWeek()->toString(), '08.01.1970 01:00:00');
     //Friday
     $date->addDay(1);
     $this->assertSame($date->getWeek()->toString(), '08.01.1970 01:00:00');
     //Friday 05:30 am
     $date->addTime('05:30:00');
     $this->assertSame($date->getWeek()->toString(), '08.01.1970 01:00:00');
     //Saturday
     $date->addDay(1);
     $this->assertSame($date->getWeek()->toString(), '08.01.1970 01:00:00');
     //Saturday [ar_EG]
     // The right value for AM/PM has to be set in arabic letters
     $this->assertSame($date->getWeek('ar_EG')->toString(), '08/01/1970 1:00:00 ص');
     $date->setTimeZone('UTC');
     $this->assertSame($date->getWeek('ar_EG')->toString(), '08/01/1970 12:00:00 ص');
     $date->setTimeZone('Europe/Vienna');
     $this->assertSame($date->getWeek('ar_EG')->toString(), '08/01/1970 1:00:00 ص');
     //Sunday [start of a new week as defined per ISO 8601]
     $date->addDay(1);
     $this->assertSame($date->getWeek()->toString(), '15.01.1970 01:00:00');
     //Monday
     $date->addDay(1);
     $this->assertSame($date->getWeek()->toString(), '15.01.1970 01:00:00');
     //Monday 03:45 pm
     $date->addTime('15:45:00');
     $this->assertSame($date->getWeek()->toString(), '15.01.1970 01:00:00');
 }
Esempio n. 29
0
 /**
  * Setup aggregated collection
  * <ol>
  * <li>Create table if not exists</li>
  * <li>Check periods to aggregate</li>
  * <li>Aggregate them</li>
  * <li>Set up collection</li>
  * </ol>
  *
  * @param datetime $from
  * @param datetime $to
  * @return AW_Advancedreports_Helper_Tools_Aggregator
  */
 public function prepareAggregatedCollection($from, $to)
 {
     $this->_validateInstance();
     # 1. Creating table if not exists
     $this->checkATable();
     # 2. Getting period to aggregate
     $periods = $this->_getPriodsToAggregate($from, $to);
     # 3. Aggreagating them
     $_expiresAt = new Zend_Date(time());
     $_expiresAt->addDay(AW_Advancedreports_Model_Aggregation::EXPIRES_AFTER);
     foreach ($periods as $period) {
         try {
             if (!isset($period['today']) || !$period['today']) {
                 $aggregating = Mage::getModel('advancedreports/aggregation')->setFrom($period['from'])->setTo($period['to'])->setTable($this->getTableName())->setData('timetype', $this->_timeType)->setData('expired', $_expiresAt->toString('Y-MM-dd'));
             }
             $this->_aggregateData($period['from'], $period['to']);
             if (!isset($period['today']) || !$period['today']) {
                 $aggregating->save();
             }
         } catch (Exception $e) {
             Mage::logException($e);
             return $this;
         }
     }
     # 4. Set up aggreagted collection
     $collection = Mage::getModel('advancedreports/cache')->getCollection();
     $collection->setPeriodFilter($from, $to);
     $collection->setMainTable($this->getTableName());
     $this->_collection = $collection;
     return $this;
 }
 /**
  * Core function calculating timeDiff
  * @param string $date
  * @param bool $now
  * @param int|string $add
  * @param bool $timestamp
  * @return Zend_Date
  * 
  */
 public static function getGmtTimestamp($date = false, $now = false, $add = false, $timestamp = true)
 {
     /* It's incorrect call of the method */
     if (!$date) {
         return false;
     }
     if (!ini_get('date.timezone')) {
         if ($timezone = Mage::app()->getStore()->getConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE)) {
             @ini_set('date.timezone', $timezone);
         }
     }
     if ($now) {
         $date = gmdate('Y-m-d H:i:s', gmdate('U'));
     }
     $date = new Zend_Date($date, Zend_Date::ISO_8601);
     $date->setTimezone('UTC');
     if ($add) {
         $date->addDay($add);
     }
     if (!$timestamp) {
         return $date;
     }
     if ($timestamp === 'toString') {
         return $date->toString('YYYY-MM-dd HH:mm:ss');
     }
     return $date->getTimestamp();
 }