BUGFIX #5157 strftime() %F format parameter does not work on Windows - use %Y-%m-%d instead (from r100795)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@108762 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Andreas Piening 2010-08-02 01:00:44 +00:00
parent e59e0431e4
commit 983fb1fc09
2 changed files with 6 additions and 6 deletions

View File

@ -363,7 +363,7 @@ JS;
if(Zend_Date::isDate($min, $this->getConfig('datavalueformat'))) {
$minDate = new Zend_Date($min, $this->getConfig('datavalueformat'));
} else {
$minDate = new Zend_Date(strftime('%F', strtotime($min)), $this->getConfig('datavalueformat'));
$minDate = new Zend_Date(strftime('%Y-%m-%d', strtotime($min)), $this->getConfig('datavalueformat'));
}
if(!$this->valueObj->isLater($minDate) && !$this->valueObj->equals($minDate)) {
$validator->validationError(
@ -383,7 +383,7 @@ JS;
if(Zend_Date::isDate($min, $this->getConfig('datavalueformat'))) {
$maxDate = new Zend_Date($max, $this->getConfig('datavalueformat'));
} else {
$maxDate = new Zend_Date(strftime('%F', strtotime($max)), $this->getConfig('datavalueformat'));
$maxDate = new Zend_Date(strftime('%Y-%m-%d', strtotime($max)), $this->getConfig('datavalueformat'));
}
if(!$this->valueObj->isEarlier($maxDate) && !$this->valueObj->equals($maxDate)) {
$validator->validationError(

View File

@ -38,24 +38,24 @@ class DateFieldTest extends SapphireTest {
function testValidateMinDateStrtotime() {
$f = new DateField('Date');
$f->setConfig('min', '-7 days');
$f->setValue(strftime('%F', strtotime('-8 days')));
$f->setValue(strftime('%Y-%m-%d', strtotime('-8 days')));
$this->assertFalse($f->validate(new RequiredFields()), 'Date below min date, with strtotime');
$f = new DateField('Date');
$f->setConfig('min', '-7 days');
$f->setValue(strftime('%F', strtotime('-7 days')));
$f->setValue(strftime('%Y-%m-%d', strtotime('-7 days')));
$this->assertTrue($f->validate(new RequiredFields()), 'Date matching min date, with strtotime');
}
function testValidateMaxDateStrtotime() {
$f = new DateField('Date');
$f->setConfig('max', '7 days');
$f->setValue(strftime('%F', strtotime('8 days')));
$f->setValue(strftime('%Y-%m-%d', strtotime('8 days')));
$this->assertFalse($f->validate(new RequiredFields()), 'Date above max date, with strtotime');
$f = new DateField('Date');
$f->setConfig('max', '7 days');
$f->setValue(strftime('%F', strtotime('7 days')));
$f->setValue(strftime('%Y-%m-%d', strtotime('7 days')));
$this->assertTrue($f->validate(new RequiredFields()), 'Date matching max date, with strtotime');
}