本文整理汇总了PHP中Zend_Date::isDate方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Date::isDate方法的具体用法?PHP Zend_Date::isDate怎么用?PHP Zend_Date::isDate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Date
的用法示例。
在下文中一共展示了Zend_Date::isDate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: convertAttribute
/**
* Set current attribute to entry (for specified product)
*
* @param Mage_Catalog_Model_Product $product
* @param Google_Service_ShoppingContent_Product $shoppingProduct
* @return Google_Service_ShoppingContent_Product
*/
public function convertAttribute($product, $shoppingProduct)
{
$effectiveDateFrom = $this->getGroupAttributeSalePriceEffectiveDateFrom();
$fromValue = $effectiveDateFrom->getProductAttributeValue($product);
$effectiveDateTo = $this->getGroupAttributeSalePriceEffectiveDateTo();
$toValue = $effectiveDateTo->getProductAttributeValue($product);
$from = $to = null;
if (!empty($fromValue) && Zend_Date::isDate($fromValue, Zend_Date::ATOM)) {
$from = new Zend_Date($fromValue, Zend_Date::ATOM);
}
if (!empty($toValue) && Zend_Date::isDate($toValue, Zend_Date::ATOM)) {
$to = new Zend_Date($toValue, Zend_Date::ATOM);
}
$dateString = null;
// if we have from an to dates, and if these dates are correct
if (!is_null($from) && !is_null($to) && $from->isEarlier($to)) {
$dateString = $from->toString(Zend_Date::ATOM) . '/' . $to->toString(Zend_Date::ATOM);
}
// if we have only "from" date, send "from" day
if (!is_null($from) && is_null($to)) {
$dateString = $from->toString('YYYY-MM-dd');
}
// if we have only "to" date, use "now" date for "from"
if (is_null($from) && !is_null($to)) {
$from = new Zend_Date();
// if "now" date is earlier than "to" date
if ($from->isEarlier($to)) {
$dateString = $from->toString(Zend_Date::ATOM) . '/' . $to->toString(Zend_Date::ATOM);
}
}
if (!is_null($dateString)) {
$shoppingProduct->setSalePriceEffectiveDate($dateString);
}
return $shoppingProduct;
}
示例2: convertAttribute
/**
* Set current attribute to entry (for specified product)
*
* @param \Magento\Catalog\Model\Product $product
* @param \Magento\Framework\Gdata\Gshopping\Entry $entry
* @return \Magento\Framework\Gdata\Gshopping\Entry
*/
public function convertAttribute($product, $entry)
{
$effectiveDateFrom = $this->getGroupAttributeSalePriceEffectiveDateFrom();
$fromValue = $effectiveDateFrom->getProductAttributeValue($product);
$effectiveDateTo = $this->getGroupAttributeSalePriceEffectiveDateTo();
$toValue = $effectiveDateTo->getProductAttributeValue($product);
$from = $to = null;
if (!empty($fromValue) && \Zend_Date::isDate($fromValue, \Zend_Date::ATOM)) {
$from = new \Magento\Framework\Stdlib\DateTime\Date($fromValue, \Zend_Date::ATOM);
}
if (!empty($toValue) && \Zend_Date::isDate($toValue, \Zend_Date::ATOM)) {
$to = new \Magento\Framework\Stdlib\DateTime\Date($toValue, \Zend_Date::ATOM);
}
$dateString = null;
// if we have from an to dates, and if these dates are correct
if (!is_null($from) && !is_null($to) && $from->isEarlier($to)) {
$dateString = $from->toString(\Zend_Date::ATOM) . '/' . $to->toString(\Zend_Date::ATOM);
}
// if we have only "from" date, send "from" day
if (!is_null($from) && is_null($to)) {
$dateString = $from->toString('YYYY-MM-dd');
}
// if we have only "to" date, use "now" date for "from"
if (is_null($from) && !is_null($to)) {
$from = new \Magento\Framework\Stdlib\DateTime\Date();
// if "now" date is earlier than "to" date
if ($from->isEarlier($to)) {
$dateString = $from->toString(\Zend_Date::ATOM) . '/' . $to->toString(\Zend_Date::ATOM);
}
}
if (!is_null($dateString)) {
$this->_setAttribute($entry, 'sale_price_effective_date', self::ATTRIBUTE_TYPE_TEXT, $dateString);
}
return $entry;
}
示例3: isValidDate
public function isValidDate($controller, $fieldname, $textName, $dateString)
{
require_once 'Zend/Date.php';
$rtn = true;
$parts = explode('-', $dateString);
if (intval($parts[1]) > 12) {
$rtn = false;
}
$parts = explode('-', $dateString);
if (intval($parts[2]) > 31) {
$rtn = false;
}
$parts = explode('-', $dateString);
if (intval($parts[0]) > 2200) {
$rtn = false;
}
$parts = explode('-', $dateString);
if (intval($parts[0]) < 1900) {
$rtn = false;
}
$rtn = $rtn and Zend_Date::isDate($dateString, 'Y-m-d');
if (!$rtn) {
$this->addError($fieldname, $textName . ' ' . t('is not a valid date') . '.');
}
return $rtn;
}
示例4: listByFilters
/**
*
* @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);
}
示例5: isValid
public function isValid($value)
{
$valueString = (string) $value;
$this->_setValue($valueString);
if ($this->_format !== null or $this->_locale !== null) {
require_once 'Zend/Date.php';
if (!Zend_Date::isDate($value, $this->_format, $this->_locale)) {
if ($this->_checkFormat($value) === false) {
$this->_error(self::FALSEFORMAT);
} else {
$this->_error(self::INVALID);
}
return false;
}
} else {
if (!preg_match('/^\\d{4}-\\d{2}-\\d{2}$/', $valueString)) {
$this->_error(self::NOT_YYYY_MM_DD);
return false;
}
list($year, $month, $day) = sscanf($valueString, '%d-%d-%d');
if (!checkdate($month, $day, $year)) {
$this->_error(self::INVALID);
return false;
}
}
return true;
}
示例6: setValue
/**
* Sets the internal value to ISO date format.
*
* @param string|array $val String expects an ISO date format. Array notation with 'date' and 'time'
* keys can contain localized strings. If the 'dmyfields' option is used for {@link DateField},
* the 'date' value may contain array notation was well (see {@link DateField->setValue()}).
*/
function setValue($val)
{
if (empty($val)) {
$this->dateField->setValue(null);
$this->timeField->setValue(null);
} else {
// String setting is only possible from the database, so we don't allow anything but ISO format
if (is_string($val) && Zend_Date::isDate($val, $this->getConfig('datavalueformat'), $this->locale)) {
// split up in date and time string values.
$valueObj = new Zend_Date($val, $this->getConfig('datavalueformat'), $this->locale);
// set date either as array, or as string
if ($this->dateField->getConfig('dmyfields')) {
$this->dateField->setValue($valueObj->toArray());
} else {
$this->dateField->setValue($valueObj->get($this->dateField->getConfig('dateformat')));
}
// set time
$this->timeField->setValue($valueObj->get($this->timeField->getConfig('timeformat')));
} elseif (is_array($val) && array_key_exists('date', $val) && array_key_exists('time', $val)) {
$this->dateField->setValue($val['date']);
$this->timeField->setValue($val['time']);
} else {
$this->dateField->setValue($val);
$this->timeField->setValue($val);
}
}
}
示例7: uploadAction
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('/');
}
示例8: addTime
/**
*
* 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;
}
示例9: filter
/**
* Filter date
*
* @param string $value
* @return null|string
*/
public function filter($value)
{
if ($value) {
$date = new Zend_Date($value, null, $this->_options['locale']);
if (Zend_Date::isDate($value, $this->_options['date_format'], $this->_options['locale'])) {
return $date->toString('yyyy-MM-dd');
} else {
return $date->toString($this->_options['date_format']);
}
}
return null;
}
示例10: formatDate
public function formatDate($date, $formatName, $formatStr = '')
{
if (!Zend_Date::isDate($date)) {
return $date;
} else {
$date = new Zend_Date($date);
if ($formatName != null && in_array($this->date_formats, $formatName)) {
return $date->toString($this->date_formats[$formatName]);
} else {
if ($formatStr != null) {
return $date->toString($formatStr);
}
}
}
}
示例11: date
/**
* Render a date into a view using the given format,
* it can be a textual representation or a Zend_Date object
*
* @param string|Zend_Date $date the date to format
* @param string $outputFormat output format for the date
* @param string $inputFormat input format of the given date,
* used only if $date is a string
*
* @return string
*/
public function date($date, $outputFormat = Zend_Date::DATE_LONG, $inputFormat = null)
{
if (!$date instanceof Zend_Date) {
// check for string type
if (!is_string($date)) {
throw new InvalidArgumentException("Input date must be string or Zend_Date");
}
if (null == $inputFormat && Zend_Date::isDate($date, 'YYYY-mm-dd')) {
// use database input format if is matched
$inputFormat = Zend_Date::ISO_8601;
}
// build a zend date object
$date = new Zend_Date($date, $inputFormat);
}
// return converted date
return $date->get($outputFormat);
}
示例12: getisvaliddateAction
public function getisvaliddateAction()
{
$this->_helper->viewRenderer->setNoRender();
$this->_helper->layout()->disableLayout();
$dateText = $this->getRequest()->getParam('dateText');
$objSelectedDate = new Zend_Date($dateText, Zend_Date::ISO_8601);
$objTodayDate = new Zend_Date(Zend_Date::now(), Zend_Date::ISO_8601);
if ($objSelectedDate->isToday($dateText)) {
echo 1;
return;
}
if ($objSelectedDate->isEarlier($objTodayDate) || $objSelectedDate->isDate($dateText)) {
echo 0;
return;
}
echo 1;
}
示例13: isValid
/**
* Returns true if and only if $value meets the validation requirements
*
* If $value fails validation, then this method returns false, and
* getMessages() will return an array of messages that explain why the
* validation failed.
*
* @param mixed $value
* @return boolean
* @throws \Zend_Valid_Exception If validation of $value is impossible
*/
public function isValid($value, $context = null)
{
try {
$date = new \Zend_Date($value, $this->getDateFormat());
} catch (\Zend_Date_Exception $e) {
$this->_error(self::NOT_VALID_DATE, $value);
return false;
}
$year = $date->get(\Zend_Date::YEAR);
/**
* Prevent extreme dates (also fixes errors when saving to the db)
*/
if ($year > 1850 && $year < 2200 && \Zend_Date::isDate($value, $this->getDateFormat())) {
return true;
}
$this->_error(self::NOT_VALID_DATE, $value);
return false;
}
示例14: indexAction
public function indexAction()
{
// Title
$this->view->breadcrumb = Snep_Breadcrumb::renderPath(array($this->view->translate("Reports"), $this->view->translate("Services Use")));
$config = Zend_Registry::get('config');
// Include Inpector class, for permission test
include_once $config->system->path->base . "/inspectors/Permissions.php";
$test = new Permissions();
$response = $test->getTests();
$form = $this->getForm();
if ($this->_request->getPost()) {
$formIsValid = $form->isValid($_POST);
$formData = $this->_request->getParams();
$locale = Snep_Locale::getInstance()->getLocale();
if ($locale == 'en_US') {
$format = 'yyyy-MM-dd';
} else {
$format = Zend_Locale_Format::getDateFormat($locale);
}
$ini_date = explode(" ", $formData['period']['init_day']);
$final_date = explode(" ", $formData['period']['till_day']);
$ini_date_valid = Zend_Date::isDate($ini_date[0], $format);
$final_date_valid = Zend_Date::isDate($final_date[0], $format);
if (!$ini_date_valid) {
$iniDateElem = $form->getSubForm('period')->getElement('init_day');
$iniDateElem->addError($this->view->translate('Invalid Date'));
$formIsValid = false;
}
if (!$final_date_valid) {
$finalDateElem = $form->getSubForm('period')->getElement('till_day');
$finalDateElem->addError($this->view->translate('Invalid Date'));
$formIsValid = false;
}
if ($formIsValid) {
$reportType = $formData['service']['out_type'];
if ($reportType == 'csv') {
$this->csvAction();
} else {
$this->viewAction();
}
}
}
$this->view->form = $form;
}
示例15: _getCurrentQuoteFieldValue
protected function _getCurrentQuoteFieldValue($fieldName, $index = null)
{
$firstItem = $this->_getCurrentOrderOrQuote($index);
if ($fieldName == 'delivery_date') {
if (Zend_Date::isDate($firstItem->getData($fieldName), Zend_Date::ISO_8601)) {
$dateTime = new Zend_Date($firstItem->getData($fieldName), Zend_Date::ISO_8601);
return $dateTime->toString('yyyy-MM-dd');
} else {
return;
}
} elseif ($fieldName == 'delivery_time') {
if (Zend_Date::isDate($firstItem->getData('delivery_date'), Zend_Date::ISO_8601)) {
$dateTime = new Zend_Date($firstItem->getData('delivery_date'), Zend_Date::ISO_8601);
return explode(':', $dateTime->get(Zend_Date::TIME_SHORT));
} else {
return;
}
}
return $firstItem->getData($fieldName);
}