Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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
  • Loading branch information...
commit 983fb1fc09675d1a23caa2a231fa7452de550b4f 1 parent e59e043
Andreas Piening authored
Showing with 6 additions and 6 deletions.
  1. +2 −2 forms/DateField.php
  2. +4 −4 tests/forms/DateFieldTest.php
4 forms/DateField.php
View
@@ -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(
@@ -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(
8 tests/forms/DateFieldTest.php
View
@@ -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');
}
Please sign in to comment.
Something went wrong with that request. Please try again.