mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUGFIX #5157 strftime() %F format parameter does not work on Windows - use %Y-%m-%d instead
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@100795 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
e7c74e0107
commit
54720e62e6
@ -363,7 +363,7 @@ JS;
|
|||||||
if(Zend_Date::isDate($min, $this->getConfig('datavalueformat'))) {
|
if(Zend_Date::isDate($min, $this->getConfig('datavalueformat'))) {
|
||||||
$minDate = new Zend_Date($min, $this->getConfig('datavalueformat'));
|
$minDate = new Zend_Date($min, $this->getConfig('datavalueformat'));
|
||||||
} else {
|
} 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)) {
|
if(!$this->valueObj->isLater($minDate) && !$this->valueObj->equals($minDate)) {
|
||||||
$validator->validationError(
|
$validator->validationError(
|
||||||
@ -383,7 +383,7 @@ JS;
|
|||||||
if(Zend_Date::isDate($min, $this->getConfig('datavalueformat'))) {
|
if(Zend_Date::isDate($min, $this->getConfig('datavalueformat'))) {
|
||||||
$maxDate = new Zend_Date($max, $this->getConfig('datavalueformat'));
|
$maxDate = new Zend_Date($max, $this->getConfig('datavalueformat'));
|
||||||
} else {
|
} 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)) {
|
if(!$this->valueObj->isEarlier($maxDate) && !$this->valueObj->equals($maxDate)) {
|
||||||
$validator->validationError(
|
$validator->validationError(
|
||||||
|
@ -38,24 +38,24 @@ class DateFieldTest extends SapphireTest {
|
|||||||
function testValidateMinDateStrtotime() {
|
function testValidateMinDateStrtotime() {
|
||||||
$f = new DateField('Date');
|
$f = new DateField('Date');
|
||||||
$f->setConfig('min', '-7 days');
|
$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');
|
$this->assertFalse($f->validate(new RequiredFields()), 'Date below min date, with strtotime');
|
||||||
|
|
||||||
$f = new DateField('Date');
|
$f = new DateField('Date');
|
||||||
$f->setConfig('min', '-7 days');
|
$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');
|
$this->assertTrue($f->validate(new RequiredFields()), 'Date matching min date, with strtotime');
|
||||||
}
|
}
|
||||||
|
|
||||||
function testValidateMaxDateStrtotime() {
|
function testValidateMaxDateStrtotime() {
|
||||||
$f = new DateField('Date');
|
$f = new DateField('Date');
|
||||||
$f->setConfig('max', '7 days');
|
$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');
|
$this->assertFalse($f->validate(new RequiredFields()), 'Date above max date, with strtotime');
|
||||||
|
|
||||||
$f = new DateField('Date');
|
$f = new DateField('Date');
|
||||||
$f->setConfig('max', '7 days');
|
$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');
|
$this->assertTrue($f->validate(new RequiredFields()), 'Date matching max date, with strtotime');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user