Skip to content

Commit

Permalink
BUGFIX #5157 strftime() %F format parameter does not work on Windows …
Browse files Browse the repository at this point in the history
…- 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
  • Loading branch information
Andreas Piening committed Aug 2, 2010
1 parent e59e043 commit 983fb1f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions forms/DateField.php
Expand Up @@ -363,7 +363,7 @@ function validate($validator) {
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(
Expand All @@ -383,7 +383,7 @@ function validate($validator) {
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(
Expand Down
8 changes: 4 additions & 4 deletions tests/forms/DateFieldTest.php
Expand Up @@ -38,24 +38,24 @@ function testValidateMinDate() {
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');
}

Expand Down

0 comments on commit 983fb1f

Please sign in to comment.