/** * */ public function informationAction() { // Form Information $formInformation = $this->_initForm('information'); $id = $this->_getParam('id'); $data = array(); if (!empty($id)) { $row = $this->_mapper->fetchRow($id); $data = $row->toArray(); $date = new Zend_Date(); $data['registration_date'] = $date->set($data['registration_date'])->toString('dd/MM/yyyy'); $data['open_date'] = $date->set($data['open_date'])->toString('dd/MM/yyyy'); $data['close_date'] = $date->set($data['close_date'])->toString('dd/MM/yyyy'); $data['start_salary'] = number_format($data['start_salary'], 2, '.', ''); $data['finish_salary'] = number_format($data['finish_salary'], 2, '.', ''); $data['additional_salary'] = number_format($data['additional_salary'], 2, '.', ''); if (!empty($data['start_job_date'])) { $data['start_job_date'] = $date->set($data['start_job_date'])->toString('dd/MM/yyyy'); } if (!$this->view->jobActive()->hasAccessEdit()) { $formInformation->getElement('save')->setAttrib('disabled', true); } } else { $data['fk_id_dec'] = Zend_Auth::getInstance()->getIdentity()->fk_id_dec; } $formInformation->populate($data); $this->view->form = $formInformation; }
/** * * @param array $filters * @return Zend_Db_Table_Rowset */ public function listByFilters($filters = array()) { $dbAudit = App_Model_DbTable_Factory::get('SysAudit'); $dbForm = App_Model_DbTable_Factory::get('SysForm'); $dbModule = App_Model_DbTable_Factory::get('SysModule'); $dbUser = App_Model_DbTable_Factory::get('SysUser'); $select = $dbAudit->select()->from(array('a' => $dbAudit))->setIntegrityCheck(false)->join(array('f' => $dbForm), 'f.id_sysform = a.fk_id_sysform', array('form', 'date_audit' => new Zend_Db_Expr('DATE_FORMAT( a.date_time, "%d/%m/%Y" )')))->join(array('m' => $dbModule), 'm.id_sysmodule = a.fk_id_sysmodule', array('module'))->join(array('u' => $dbUser), 'u.id_sysuser = a.fk_id_sysuser', array('name'))->order(array('date_time DESC')); $date = new Zend_Date(); if (!empty($filters['start_date']) && Zend_Date::isDate($filters['start_date'])) { $select->where('DATE( a.date_time ) >= ?', $date->set($filters['start_date'])->toString('yyyy-MM-dd')); } if (!empty($filters['finish_date']) && Zend_Date::isDate($filters['finish_date'])) { $select->where('DATE( a.date_time ) <= ?', $date->set($filters['finish_date'])->toString('yyyy-MM-dd')); } if (!empty($filters['fk_id_sysuser'])) { $select->where('a.fk_id_sysuser = ?', $filters['fk_id_sysuser']); } if (!empty($filters['fk_id_sysmodule'])) { $select->where('a.fk_id_sysmodule = ?', $filters['fk_id_sysmodule']); } if (!empty($filters['fk_id_sysform'])) { $select->where('a.fk_id_sysform = ?', $filters['fk_id_sysform']); } if (!empty($filters['description'])) { $select->where('a.description LIKE ?', '%' . $filters['description'] . '%'); } return $dbAudit->fetchAll($select); }
/** * Generates a set of radio button elements. * * @access public * * @param string|array $name If a string, the element name. If an * array, all other parameters are ignored, and the array elements * are extracted in place of added parameters. * * @param mixed $value The radio value to mark as 'checked'. * * @param array $options An array of key-value pairs where the array * key is the radio value, and the array value is the radio text. * * @param array|string $attribs Attributes added to each radio. * * @return string The radio buttons XHTML. */ public function formDate($name, $value = null, $attribs = null, $options = null, $listsep = "<br />\n") { if (is_string($value)) { $parsedValue = array(); list($parsedValue['year'], $parsedValue['month'], $parsedValue['day']) = @explode('-', $value, 3); list($parsedValue['day'], $time) = @explode(' ', $parsedValue['day'], 2); $value = $parsedValue; } if (!is_array($value)) { $value = null; } $info = $this->_getInfo($name, $value, $attribs, $options, $listsep); extract($info); // name, value, attribs, options, listsep, disable $localeObject = Zend_Registry::get('Locale'); // Translate year names from locale $yearFormat = $localeObject->getTranslation('yyyy', 'dateitem', $localeObject); if ($yearFormat) { $date = new Zend_Date(); foreach ($options['year'] as $key => &$val) { if ($key <= 0) { continue; } $date->set($key, Zend_Date::YEAR); $val = $date->toString($yearFormat, 'iso', $localeObject); } } // Translate month names from locale $monthLabels = $localeObject->getTranslationList('Month', $localeObject); if (isset($options['month'][0]) && count($monthLabels) + 1 == count($options['month'])) { array_unshift($monthLabels, ''); } if (count($monthLabels) == count($options['month'])) { $options['month'] = array_combine(array_keys($options['month']), array_values($monthLabels)); } // Translate day names from locale $dayFormat = $localeObject->getTranslation('d', 'dateitem', $localeObject); if ($dayFormat) { $date = new Zend_Date(); $date->set(1, Zend_Date::MONTH); foreach ($options['day'] as $key => &$val) { if ($key <= 0) { continue; } $date->set($key, Zend_Date::DAY); $val = $date->toString($dayFormat, 'iso', $localeObject); } } // Get order from locale $dateLocaleString = $localeObject->getTranslation('long', 'Date', $localeObject); $dateLocaleString = preg_replace('~\'[^\']+\'~', '', $dateLocaleString); $dateLocaleString = strtolower($dateLocaleString); $dateLocaleString = preg_replace('/[^mdy]/i', '', $dateLocaleString); $dateLocaleString = preg_replace(array('/(m)+/', '/(d)+/', '/(y)+/'), array(' %2$s ', ' %3$s ', ' %1$s '), $dateLocaleString); $dateLocaleString = preg_replace('/ +/i', ' ', trim($dateLocaleString)); return sprintf($dateLocaleString, $this->view->formSelect($name . '[year]', $value['year'], $attribs, $options['year']), $this->view->formSelect($name . '[month]', $value['month'], $attribs, $options['month']), $this->view->formSelect($name . '[day]', $value['day'], $attribs, $options['day'])); }
public function findallAction() { if ($value_id = $this->getRequest()->getParam('value_id')) { try { $option = $this->getCurrentOptionValue(); $start_at = new Zend_Date(); $end_at = new Zend_Date(); $format = 'y-MM-dd HH:mm:ss'; $offset = $this->getRequest()->getParam('offset', 0); $events = $option->getObject()->getEvents($offset); $data = array('collection' => array()); foreach ($events as $key => $event) { $start_at->set($event->getStartAt(), $format); $end_at->set($event->getEndAt(), $format); $formatted_start_at = $start_at->toString($this->_("MM.dd.y")); $subtitle2 = $this->_("Entrance: %s", $event->getStartTimeAt()); if ($event->getLocationLabel()) { $subtitle2 .= " | " . $this->_("Location: %s", $event->getLocationLabel()); } $data['collection'][] = array("id" => $key, "title" => $event->getName(), "title2" => "{$start_at->toString(Zend_Date::WEEKDAY_NAME)} {$formatted_start_at}", "name" => $event->getName(), "subtitle" => $event->getSubtitle(), "subtitle2" => $subtitle2, "description" => $event->getDescription(), "month_name_short" => $start_at->toString(Zend_Date::MONTH_NAME_SHORT), "day" => $start_at->toString('dd'), "weekday_name" => $start_at->toString(Zend_Date::WEEKDAY_NAME), "start_time_at" => $event->getStartTimeAt(), "location" => $event->getLocation(), "url" => $this->getPath("event/mobile_view/index", array('value_id' => $option->getId(), "event_id" => $key))); } $data['page_title'] = $option->getTabbarName(); $data['displayed_per_page'] = Event_Model_Event::DISPLAYED_PER_PAGE; } catch (Exception $e) { $data = array('error' => 1, 'message' => $e->getMessage()); } $this->_sendHtml($data); } }
public function testDate() { //$date = new Zend_Date('12:01',Zend_Date::TIME_SHORT); $date = new Zend_Date(); $time = '12:01'; $date->set($time, Zend_Date::TIME_SHORT); }
public function convertDateToStoreTimestamp($date, $store = null) { try { if (Mage::getStoreConfigFlag('xtcore/compatibility_fixes/disable_timestamp_timezone_adjustment')) { $dateObj = new Zend_Date(); $dateObj->set($date, Varien_Date::DATETIME_INTERNAL_FORMAT); return (int) $dateObj->get(null, Zend_Date::TIMESTAMP); } $dateObj = new Zend_Date(); $dateObj->setTimezone(Mage_Core_Model_Locale::DEFAULT_TIMEZONE); $dateObj->set($date, Varien_Date::DATETIME_INTERNAL_FORMAT); $dateObj->setLocale(Mage::getStoreConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_LOCALE, $store)); $dateObj->setTimezone(Mage::getStoreConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE, $store)); $gmtOffset = $dateObj->getGmtOffset(); if ($gmtOffset >= 0) { if (Mage::getStoreConfigFlag('xtcore/compatibility_fixes/zend_date_gmt_offset')) { // Note: Some Zend_Date versions always return a positive $gmtOffset. Thus, we replace + with - below if affected by this. return (int) $dateObj->get(null, Zend_Date::TIMESTAMP) - $gmtOffset; } else { return (int) $dateObj->get(null, Zend_Date::TIMESTAMP) + $gmtOffset; } } else { return (int) $dateObj->get(null, Zend_Date::TIMESTAMP) - $gmtOffset; } } catch (Exception $e) { return null; } }
/** * * @param string $value * @return Zend_Date */ public function filter($value){ $d = new Zend_Date(); $d->setTimezone('Europe/London'); $d->set($value, 'yyyy-MM-dd hh-mm-ss'); $d->setTimezone(); return $d; }
/** * Returns the date. * * @return Zend_Date */ public function getDate() { $date = new Zend_Date(0); $date->setTimezone('UTC'); $date->set($this->getText(), $this->_format ? $this->_format : Zend_Date::ISO_8601); return $date; }
public function uploadAction() { if (isset($_FILES['importfile']) && !empty($_FILES['importfile']['name'])) { $content = file_get_contents($_FILES['importfile']['tmp_name']); $lines = explode("\n", $content); $persons = array(); //'BDAY' $state = 0; foreach ($lines as $line) { $line = str_replace("\r", "", $line); $pos = strpos($line, ':'); if ($pos === false) { continue; } $key = substr($line, 0, $pos); $value = substr($line, $pos + 1); switch ($state) { case 0: if ($key === 'BEGIN' && $value === 'VCARD') { $state = 1; $person = array(); } break; case 1: if ($key === 'END' && $value === 'VCARD') { $state = 0; $persons[] = $person; } else { if ($key === 'FN' || substr($key, 0, 3) === 'FN;') { $name = explode(' ', $value); $person['firstname'] = strip_tags($name[0]); $person['secondname'] = strip_tags($name[1]); } if ($key === 'BDAY' || substr($key, 0, 5) === 'BDAY;') { $value = substr($value, 0, 10); $date = new Zend_Date(); if ($date->isDate($value, 'yyyy-MM-dd')) { $date->set($value); $person['birthdate'] = $date->toString('yyyy-MM-dd'); } } } break; } } } foreach ($persons as $person) { if (isset($person['firstname']) && isset($person['secondname']) && isset($person['birthdate'])) { $user = new Bc_UserDTO(); $user->set('firstname', $person['firstname']); $user->set('secondname', $person['secondname']); $user->set('birthdate', $person['birthdate']); $user->save(); } } $this->_redirect('/'); }
public function __construct($noMonths, Zend_Date $startDate = null) { $this->_noMonths = (int) $noMonths; if (is_null($startDate)) { $startDate = new Zend_Date(); $startDate->set(1, Zend_Date::DAY); } $this->_startDate = $startDate; $this->buildCalendar(); }
/** * * Enter description here ... * @param unknown_type $time * @param unknown_type $format * @return ExecutionTime * @throws Exception */ public function addTime($time, $format = 'HH:mm:ss') { if (!\Zend_Date::isDate($time, $format)) { throw new \Exception('time invalid ' . $time); } $date = new \Zend_Date(); $date->set($time, $format); $this->dates[] = $date; return $this; }
/** * * @access protected * @return int */ protected function _firstWeekday() { $day = (int) $this->_date->toString('dd'); //Seleciona primeiro dia do mes $this->_date->set(1, Zend_Date::DAY); //Dia da semana $weekday = $this->_date->get(Zend_Date::WEEKDAY_DIGIT); $this->_date->set($day, Zend_Date::DAY); return $weekday; }
/** * Converte um timestamp para array * * @param int $timeStamp * @return ARRAY */ public function unixToArray($timeStamp) { if (!$timeStamp) return null; $date = new Zend_Date(); $date->set($timeStamp, Zend_Date::TIMESTAMP); return $date->toArray(); }
/** * Convert given date string with UTC timezone into default locale format * and locale timezone * * @param string $date date string in SQL format with UTC timezone * @return Zend_Date */ public static function getDateFromDb($date) { if (!is_string($date)) { throw new Zmz_Date_Exception('$date must be a string'); } $tmpDate = new Zend_Date(); $tmpDate->setTimezone('UTC'); $tmpDate->set($date, self::SQL_DATETIME); $tmpDate->setTimezone(Zmz_Culture::getTimezone()); return $tmpDate; }
/** * Zwraca zapytanie SQL * * @return string */ public function buildSQl() { $select = $this->dbModelTable->select(); $select->setIntegrityCheck(false)->from(array('ss' => 'sms.storage'), array(new Zend_Db_Expr('DISTINCT ON (id) ss.*')))->joinRight(array('sss' => 'sms.storage_status'), 'ss.id = sss.sms_storage_id', array())->joinLeft(array('wc' => 'ws.client'), 'wc.id = ss.ws_client_id', array('client_name'))->joinLeft(array('ws' => 'ws.service_sms'), 'ws.id = ss.ws_service_sms_id', array('service_login'))->joinLeft(array('sr' => 'ws.recipient_sms'), 'sr.id = ss.sms_recipient_id', array('recipient' => 'phone_number'))->where('sr.id = ?', $this->id); if (isset($this->filterdata['client_id']) && !empty($this->filterdata['client_id'])) { $select->where('ss.ws_client_id = ?', $this->filterdata['client_id']); } if (isset($this->filterdata['service_id']) && !empty($this->filterdata['service_id'])) { $select->where('ss.ws_service_sms_id = ?', $this->filterdata['service_id']); } $date = new Zend_Date(); if (isset($this->filterdata['date_for']) && !empty($this->filterdata['date_for']) && isset($this->filterdata['date_to']) && !empty($this->filterdata['date_to'])) { $select->where('ss.created_at BETWEEN \'' . $date->set($this->filterdata['date_for'])->get(Zend_Date::ISO_8601) . '\' AND \'' . $date->set($this->filterdata['date_to'])->addDay(1)->get(Zend_Date::ISO_8601) . '\''); } elseif (isset($this->filterdata['date_for']) && !empty($this->filterdata['date_for'])) { $select->where('ss.created_at >= ?', $date->set($this->filterdata['date_for'])->get(Zend_Date::ISO_8601)); } elseif (isset($this->filterdata['date_to']) && !empty($this->filterdata['date_to'])) { $select->where('ss.created_at <= ?', $date->set($this->filterdata['date_to'])->addDay(1)->get(Zend_Date::ISO_8601)); } return $select->__toString(); }
protected function _convertDate($date, $locale) { $dateObj = new Zend_Date(); //set begining of day $dateObj->setHour(00); $dateObj->setMinute(00); $dateObj->setSecond(00); //set date with applying timezone of store $dateObj->set($date, Zend_Date::DATE_SHORT, $locale); return $dateObj; }
/** * Zwraca zapytanie SQL * * @return string */ public function buildSQl() { $select = $this->dbModelTable->select(); $select->setIntegrityCheck(false)->from(array('ms' => 'mail.storage'))->joinLeft(array('wc' => 'ws.client'), 'wc.id = ms.ws_client_id', array('client_name'))->joinLeft(array('ws' => 'ws.service_mail'), 'ws.id = ms.ws_service_id', array('sender_address'))->joinLeft(array('mr' => 'ws.recipient_mail'), 'mr.id = ms.mail_recipient_id', array('recipient' => 'email_address'))->where('mr.id = ?', $this->id); if (isset($this->filterdata['client_id']) && !empty($this->filterdata['client_id'])) { $select->where('ms.ws_client_id = ?', $this->filterdata['client_id']); } if (isset($this->filterdata['service_id']) && !empty($this->filterdata['service_id'])) { $select->where('ms.ws_service_id = ?', $this->filterdata['service_id']); } $date = new Zend_Date(); if (isset($this->filterdata['date_for']) && !empty($this->filterdata['date_for']) && isset($this->filterdata['date_to']) && !empty($this->filterdata['date_to'])) { $select->where('ms.created_at BETWEEN \'' . $date->set($this->filterdata['date_for'])->get(Zend_Date::ISO_8601) . '\' AND \'' . $date->set($this->filterdata['date_to'])->addDay(1)->get(Zend_Date::ISO_8601) . '\''); } elseif (isset($this->filterdata['date_for']) && !empty($this->filterdata['date_for'])) { $select->where('ms.created_at >= ?', $date->set($this->filterdata['date_for'])->get(Zend_Date::ISO_8601)); } elseif (isset($this->filterdata['date_to']) && !empty($this->filterdata['date_to'])) { $select->where('ms.created_at <= ?', $date->set($this->filterdata['date_to'])->addDay(1)->get(Zend_Date::ISO_8601)); } return $select->__toString(); }
/** * Imprime a data no formato correto * * @param date $d Data a ser impressa * @param string $format Formato da data * @param string $locale Localização da data * */ public function getTime($d, $format = null, $locale = null) { // Define o formato if (!isset($format)) { $format = Zend_Date::ISO_8601; } elseif ($format == 'twitter') { $format = 'EEE MMM dd HH:mm:ss ZZZ yyyy'; $locale = 'en_US'; } elseif ($format == 'fb') { $format = 'EEE, MMM dd yyyy HH:mm:ss ZZZ'; $locale = 'en_US'; } // Cria a data $date = new Zend_Date($d, $format, $locale); $date->setLocale('pt_BR')->setTimezone('America/Sao_Paulo'); if ($date->get('Y') == 0) { $date->set(date('Y'), 'Y'); } //echo "<br/><b>$d => " . $date->get('Y') .'</b>'; // Calcula a diferença $now = time(); $time = $now - $date->getTimestamp(); // Formata a hora if ($time < 60) { $time .= ' segundos'; } elseif ($time < 3600) { //60*60 $time = round(floatval($time) / 60) . ' minutos'; } elseif ($time < 7200) { //60*60*2 $time = round(floatval($time) / 3660) . ' hora'; } elseif ($time < 86400) { //60*60*24 $time = round(floatval($time) / 3660) . ' horas'; } elseif ($time < 604800) { //60*60*24*30 $time = round(floatval($time) / 86400) . ' dias'; } elseif ($time > 1209600 && $time <= 2592000) { //60*60*24*(7*4) $time = round(floatval($time) / 604800) . ' semanas'; } elseif ($time > 2592000 && $time <= 5184000) { //60*60*24*30 && 60*60*24*30*2 $time = round(floatval($time) / 2592000) . ' mês'; } elseif ($time > 5184000 && $time < 31104000) { //60*60*24*30*2 && 60*60*24*30*12 $time = round(floatval($time) / 2592000) . ' meses'; } else { //if ($time < 31104000) { //60*60*24*30*12 $time = ' mais de um ano (' . $date->toString() . ')'; } return $time; }
public function date($dateString = null) { /*$date = new Zend_Date(); Zend_Debug::dump($date->getDate($_SESSION['locale']['localename'])); Zend_Debug::dump($date->getTimestamp()); Zend_Debug::dump($date->get(Zend_Date::DATE_FULL)); Zend_Debug::dump($date->toString("YYYY-MM-dd HH:mm:ss"));*/ //Zend_Date::setOptions(array('format_type' => 'php')); //$date = new Zend_Date($dateString, Zend_Date::TIMESTAMP); //locale在1.70后默认会从注册表中寻找Zend_Locale $date = new Zend_Date(); $date->set($dateString, Zend_Date::TIMESTAMP); //表示$dateString的类型 return $date->get(Zend_Date::DATE_FULL); }
public function get($idproject = null) { $account = new Model_Account(); $idaccount = $account->getId(); $data = $this->_dbTable->getStream($idaccount, $idproject); $date = new Zend_Date(); $return = array(); foreach ($data as $item) { $datum = $date->set($item->datetime); $key = $datum->get(Zend_Date::DATE_FULL); $return[$key][] = $item; } return $return; }
/** * Check if data transfer is activated and if enough time has passed since the last request * * @return bool */ public function showTracking() { if (!Mage::getStoreConfig('germanstoreconfig/installation_id')) { return false; } if (Mage::getStoreConfig('admin/germanstoreconfig/datatransfer') == IntegerNet_GermanStoreConfig_Model_Source_Datatransfer::DATATRANSFER_NONE) { return false; } $lastTransferDate = Mage::getStoreConfig('germanstoreconfig/transfer_date'); if (!$lastTransferDate) { return true; } date_default_timezone_set(Mage::getStoreConfig('general/locale/timezone')); $lastTransferDateObject = new Zend_Date(); $lastTransferDateObject->set($lastTransferDate, Zend_Date::ISO_8601); return $lastTransferDateObject->add(self::DAYS_BETWEEN_TRACKING_REQUESTS, Zend_Date::DAY)->isEarlier(new Zend_Date()); }
/** * Convert given date string with UTC timezone into default locale format * and locale timezone * * @param string $date date string in SQL format with UTC timezone * @param string $defaultDate date to use if $date is null * @return Zend_Date */ public static function getDateFromDb($date, $defaultDate = null) { if ($defaultDate == null) { $defaultDate = "1970-01-01 00:00:00"; } if (null === $date) { $date = $defaultDate; } if (!is_string($date)) { throw new Exception('$date must be a string'); } $tmpDate = new Zend_Date(); $tmpDate->setTimezone('UTC'); $tmpDate->set($date, self::SQL_DATETIME); $tmpDate->setTimezone(Zmz_Culture::getTimezone()); return $tmpDate; }
/** * Takes a "field" and grabs all the corresponding disparate fields from $_POST and translates into a timestamp * @param string $field The name of the field to translate * @param array $arr = null The array containing the value. If null (default) we'll use $_POST * @return string|false $dateTime In case of success returns the timestamp (in the format 'Y-m-d H:i:s' or 'Y-m-d'), otherwise returns false ($field value is not in the array) or '' (if $field value is empty). * If $field has both date and time, the resulting value will be converted fro user timezone to system timezone. * If $field has only date and not time, no timezone conversion will occur. */ public function translate($field, $arr = null) { if ($arr == null) { $arr = $_POST; } /* @var $dateHelper DateHelper */ $dateHelper = Loader::helper('date'); if (isset($arr[$field . '_dt'])) { $value = $arr[$field . '_dt']; if (strlen(trim($value)) === 0) { return ''; } $format = defined('CUSTOM_DATE_APP_GENERIC_MDY') ? CUSTOM_DATE_APP_GENERIC_MDY : t('n/j/Y'); $h = is_numeric($arr[$field . '_h']) ? $arr[$field . '_h'] : '00'; $m = is_numeric($arr[$field . '_m']) ? $arr[$field . '_m'] : '00'; if (isset($arr[$field . '_a'])) { if ($arr[$field . '_a'] === 'AM') { $a = $dateHelper->date('A', mktime(1)); } else { $a = $dateHelper->date('A', mktime(13)); } $value .= " {$h}:{$m} {$a}"; $format .= ' h:i A'; } else { $value .= " {$h}:{$m}"; $format .= ' H:i'; } $d = new Zend_Date(); $d->setTimezone($dateHelper->getTimezone('user')); $d->set($value, $format, Localization::activeLocale()); return $dateHelper->formatCustom('Y-m-d H:i:s', $d, 'system'); } elseif (isset($arr[$field])) { $value = $arr[$field]; if (strlen(trim($value)) === 0) { return ''; } $format = defined('CUSTOM_DATE_APP_GENERIC_MDY') ? CUSTOM_DATE_APP_GENERIC_MDY : t('n/j/Y'); $d = new Zend_Date(); $d->setTimezone($dateHelper->getTimezone('system')); $d->set($value, $format, Localization::activeLocale()); return $dateHelper->formatCustom('Y-m-d', $d, 'system'); } else { return false; } }
public function convertDateToStoreTimestamp($date, $store = null) { try { $dateObj = new Zend_Date(); $dateObj->setTimezone(Mage_Core_Model_Locale::DEFAULT_TIMEZONE); $dateObj->set($date, Varien_Date::DATETIME_INTERNAL_FORMAT); $dateObj->setLocale(Mage::getStoreConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_LOCALE, $store)); $dateObj->setTimezone(Mage::getStoreConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE, $store)); $gmtOffset = $dateObj->getGmtOffset(); if ($gmtOffset >= 0) { return (int) $dateObj->get(null, Zend_Date::TIMESTAMP) + $gmtOffset; } else { return (int) $dateObj->get(null, Zend_Date::TIMESTAMP) - $gmtOffset; } } catch (Exception $e) { return null; } }
public function convertDateToStoreTimestamp($date, $store = null) { try { $dateObj = new Zend_Date(); $dateObj->setTimezone(Mage_Core_Model_Locale::DEFAULT_TIMEZONE); $dateObj->set($date, Varien_Date::DATETIME_INTERNAL_FORMAT); $dateObj->setLocale(Mage::getStoreConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_LOCALE, $store)); $dateObj->setTimezone(Mage::getStoreConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE, $store)); $gmtOffset = $dateObj->getGmtOffset(); if ($gmtOffset >= 0) { // Note: Some Zend_Date versions always return a positive $gmtOffset. Thus, replace + with - below if you're affected by this. return (int) $dateObj->get(null, Zend_Date::TIMESTAMP) + $gmtOffset; } else { return (int) $dateObj->get(null, Zend_Date::TIMESTAMP) - $gmtOffset; } } catch (Exception $e) { return null; } }
/** * * @return int|bool */ public function save() { $dbAdapter = Zend_Db_Table_Abstract::getDefaultAdapter(); $dbAdapter->beginTransaction(); try { $date = new Zend_Date($this->_data['date_appointment']); $date->set($this->_data['time_appointment'], Zend_Date::TIME_SHORT); $dataForm = $this->_data; $today = new Zend_Date(); $this->_data['date_appointment'] = $date->toString('yyyy-MM-dd HH:mm'); if (empty($this->_data['id_appointment'])) { if ($date->isEarlier($today)) { $this->_message->addMessage('Erro: Data no Oras ba audiensia uluk data ohin.', App_Message::ERROR); $this->addFieldError('date_appointment')->addFieldError('time_appointment'); return false; } $mapperCase = new Client_Model_Mapper_Case(); $case = $mapperCase->detailCase($this->_data['fk_id_action_plan']); $this->_data['fk_id_perdata'] = $case->fk_id_perdata; $this->_data['appointment_active'] = 1; $this->_data['appointment_filled'] = 0; } // Save the Note $id = parent::_simpleSave(); // Delete and insert all objetives $dbAppointmentObjective = App_Model_DbTable_Factory::get('Appointment_has_Objective'); $where = array($dbAdapter->quoteInto('fk_id_appointment = ?', $id)); $dbAppointmentObjective->delete($where); // Insert the news objectives foreach ($dataForm['objective'] as $objective) { $row = $dbAppointmentObjective->createRow(); $row->fk_id_appointment = $id; $row->fk_id_appointment_objective = $objective; $row->save(); } $dbAdapter->commit(); return $id; } catch (Exception $e) { $dbAdapter->rollBack(); $this->_message->addMessage($this->_config->messages->error, App_Message::ERROR); return false; } }
public function timeShift($datetime) { if ($this->_timezone == 'PST') { $dateObj = new Zend_Date($datetime, null, Mage::app()->getLocale()->getLocaleCode()); $dateObj->setTimezone('America/Los_Angeles'); $dateObj->set($datetime, Varien_Date::DATETIME_INTERNAL_FORMAT); $dateObj->setTimezone('UTC'); return $dateObj->toString(Varien_Date::DATETIME_INTERNAL_FORMAT); } elseif ($this->_timezone == 'PST4PM') { $dateObj = new Zend_Date($datetime, null, Mage::app()->getLocale()->getLocaleCode()); $dateObj->setTimezone('EST'); $dateObj->set($datetime, Varien_Date::DATETIME_INTERNAL_FORMAT); $dateObj->setTimezone('America/Denver'); return $dateObj->toString(Varien_Date::DATETIME_INTERNAL_FORMAT); } else { //UTC return $datetime; } }
/** * constructor for datetime class * * @param object $date OPTIONAL DateTime object */ public function __construct($date = null) { if ($date instanceof Zend_Date) { $this->date = $date; } elseif ($date instanceof DateTime) { $d = new Zend_Date(); $d->set($date->getTimestamp()); $this->date = $d; } elseif ($date != null) { $d = new Zend_Date(); $d->set($date); $this->date = $d; } else { // get config $config = Knowledgeroot_Registry::get('config'); // create date object with timezone $this->date = new Zend_Date(); $this->date->setTimezone($config->base->timezone); } }
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; }
public function findAction() { if ($value_id = $this->getRequest()->getParam('value_id')) { $event_id = $this->getRequest()->getParam('event_id'); if (is_null($event_id)) { return $this; } try { $option = $this->getCurrentOptionValue(); $start_at = new Zend_Date(); $end_at = new Zend_Date(); $format = 'y-MM-dd HH:mm:ss'; $events = $option->getObject()->getEvents(null, true); if (!empty($events[$event_id])) { $event = $events[$event_id]; $data = array('event' => array()); $start_at->set($event->getStartAt(), $format); $end_at->set($event->getEndAt(), $format); $formatted_start_at = $start_at->toString($this->_("MM.dd.y")); $formatted_end_at = $end_at->toString($this->_("MM.dd.y 'at' HH:mm a")); $in_app_page_path = null; if (is_numeric($event->getInAppValueId())) { $option = new Application_Model_Option_Value(); $option->find($event->getInAppValueId()); if ($option->getId() and $option->isActive() and $option->getAppId() == $this->getApplication()->getId()) { $in_app_page_path = $option->getPath("index"); } } $data['event'] = array("id" => $event_id, "title" => $event->getName(), "description" => $event->getDescription(), "address" => $event->getAddress(), "weekday_name" => $start_at->toString(Zend_Date::WEEKDAY_NAME), "start_at" => $formatted_start_at, "end_at" => $formatted_end_at, "ticket_shop_url" => $event->getTicketShopUrl(), "rsvp" => $event->getRsvp(), "websites" => $event->getWebsites(), "in_app_page_path" => $in_app_page_path, "social_sharing_active" => $option->getSocialSharingIsActive()); $data["cover"] = array("title" => $event->getName(), "subtitle" => $event->getSubtitle(), "title2" => "{$start_at->toString(Zend_Date::WEEKDAY_NAME)} {$formatted_start_at}", "subtitle2" => array("time" => $event->getStartTimeAt(), "location" => array("label" => $event->getLocationLabel(), "url" => $event->getLocationUrl())), "title3" => "{$end_at->toString(Zend_Date::WEEKDAY_NAME)} {$formatted_end_at}", "picture" => $event->getPicture()); $data['page_title'] = $event->getName(); } else { throw new Exception("Unable to find this event."); } } catch (Exception $e) { $data = array('error' => 1, 'message' => $e->getMessage()); } $this->_sendHtml($data); } }