Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Merge b959478 into 1e34504
Browse files Browse the repository at this point in the history
  • Loading branch information
alirezameskin committed Jun 16, 2017
2 parents 1e34504 + b959478 commit f93da20
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Element/DateTime.php
Expand Up @@ -226,7 +226,7 @@ public function getInputSpecification()
private function valueIsValidDateTimeFormat($value)
{
return PhpDateTime::createFromFormat(
static::DATETIME_FORMAT,
$this->format,
$value
) instanceof DateTimeInterface;
}
Expand Down
7 changes: 7 additions & 0 deletions src/Element/Month.php
Expand Up @@ -27,6 +27,13 @@ class Month extends DateTime
'type' => 'month',
];

/**
* A valid format string accepted by date()
*
* @var string
*/
protected $format = self::DATETIME_FORMAT;

/**
* Retrieves a Date Validator configured for a Month Input type
*
Expand Down
4 changes: 2 additions & 2 deletions test/Element/DateTest.php
Expand Up @@ -128,14 +128,14 @@ public function testCorrectFormatPassedToDateValidator()
'min' => '2012-01-01',
'max' => '2012-12-31',
]);
$element->setFormat('d-m-Y');
$element->setFormat('Y-m-d');

$inputSpec = $element->getInputSpecification();
foreach ($inputSpec['validators'] as $validator) {
switch (get_class($validator)) {
case 'Zend\Validator\DateStep':
case 'Zend\Validator\Date':
$this->assertEquals('d-m-Y', $validator->getFormat());
$this->assertEquals('Y-m-d', $validator->getFormat());
break;
}
}
Expand Down

0 comments on commit f93da20

Please sign in to comment.