本文整理汇总了PHP中Zend_Validate_Date::setLocale方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Validate_Date::setLocale方法的具体用法?PHP Zend_Validate_Date::setLocale怎么用?PHP Zend_Validate_Date::setLocale使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Validate_Date
的用法示例。
在下文中一共展示了Zend_Validate_Date::setLocale方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testUseLocaleFormat
/**
* Ensures that the validator can handle different dateformats from locale
*
* @see http://framework.zend.com/issues/browse/ZF-2003
* @return void
*/
public function testUseLocaleFormat()
{
$valuesExpected = array('10.01.2008' => true, '32.02.2008' => false, '20 April 2008' => true, '1 Jul 2008' => true, '2008/20/03' => false, '99/99/2000' => false, 0 => false, 999999999999 => false, 'Jan 1 2007' => false);
foreach ($valuesExpected as $input => $result) {
$this->assertEquals($result, $this->_validator->setLocale('de_AT')->isValid($input), "'{$input}' expected to be " . ($result ? '' : 'in') . 'valid');
}
}
示例2: testUseLocaleFormat
/**
* Ensures that the validator can handle different dateformats from locale
*
* @see http://framework.zend.com/issues/browse/ZF-2003
* @return void
*/
public function testUseLocaleFormat()
{
$errorOccurredLocal = false;
set_error_handler(array($this, 'errorHandlerIgnore'));
$valuesExpected = array('10.01.2008' => true, '32.02.2008' => false, '20 April 2008' => true, '1 Jul 2008' => true, '2008/20/03' => false, '99/99/2000' => false, 0 => false, 999999999999 => false, 'Jan 1 2007' => false);
foreach ($valuesExpected as $input => $resultExpected) {
$resultActual = $this->_validator->setLocale('de_AT')->isValid($input);
if (!$this->_errorOccurred) {
$this->assertEquals($resultExpected, $resultActual, "'{$input}' expected to be " . ($resultExpected ? '' : 'in') . 'valid');
} else {
$errorOccurredLocal = true;
}
$this->_errorOccurred = false;
}
restore_error_handler();
if ($errorOccurredLocal) {
$this->markTestSkipped('Affected by bug described in ZF-2789');
}
}
示例3: setLocale
/**
* Sets locale and updated input format automatically.
* @param Zend_Locale $locale
*/
public function setLocale($locale = null)
{
parent::setLocale($locale);
if ($locale instanceof Zend_Locale) {
$dateFormat = $this->getDateFormat($locale->getLanguage());
$inputPattern = $this->getDatePattern($locale->getLanguage());
} else {
$dateFormat = $this->getDateFormat($locale);
$inputPattern = $this->getDatePattern($locale);
}
$this->setFormat($dateFormat);
$this->setInputPattern($inputPattern);
}