Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Jan 8, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions library/Zend/Form/Element/Date.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace Zend\Form\Element;

use DateInterval;
use DateTimezone;
use Zend\Form\Element;
use Zend\Form\Element\DateTime as DateTimeElement;
use Zend\Validator\DateStep as DateStepValidator;
Expand Down Expand Up @@ -50,6 +51,7 @@ protected function getStepValidator()
return new DateStepValidator(array(
'format' => $format,
'baseValue' => $baseValue,
'timezone' => new DateTimezone("UTC"),
'step' => new DateInterval("P{$stepValue}D"),
));
}
Expand Down
39 changes: 39 additions & 0 deletions tests/ZendTest/Form/Element/DateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,29 @@

class DateTest extends TestCase
{
/**
* Stores the original set timezone
*
* @var string
*/
private $originaltimezone;

/**
* Setup environment
*/
public function setUp()
{
$this->originaltimezone = date_default_timezone_get();
}

/**
* Tear down environment
*/
public function tearDown()
{
date_default_timezone_set($this->originaltimezone);
}

public function testProvidesDefaultInputSpecification()
{
$element = new DateElement('foo');
Expand Down Expand Up @@ -113,4 +136,20 @@ public function testCorrectFormatPassedToDateValidator()
}
}
}

public function testStepValidatorIgnoresDaylightSavings()
{
date_default_timezone_set('Europe/London');

$element = new DateElement('foo');

$inputSpec = $element->getInputSpecification();
foreach ($inputSpec['validators'] as $validator) {
switch (get_class($validator)) {
case 'Zend\Validator\DateStep':
$this->assertTrue($validator->isValid('2013-12-25'));
break;
}
}
}
}