Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Use RFC-3339 full-date format (Y-m-d) in Date element #2690

Merged
merged 1 commit into from

3 participants

Matthew Weier O'Phinney Christopher Martin Ralph Schindler
Ralph Schindler
Collaborator

Will merge, although I am curious why this file has a use statement, and an alias for a class in the current namespace:
https://github.com/weierophinney/zf2/blob/0029ccdc82aad1a7a8fb85bcfaf779fcfd19a124/library/Zend/Form/Element/Date.php#L14

Either way thats not a blocker, looks good.

Ralph Schindler
Collaborator

I am also assuming this is a bug and should be merged in for 2.0.3.

Ralph Schindler ralphschindler merged commit 0029ccd into from
Matthew Weier O'Phinney

Correct on both accounts. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
8 library/Zend/Form/Element/Date.php
View
@@ -34,6 +34,14 @@ class Date extends DateTimeElement
);
/**
+ * Date format to use for DateTime values. By default, this is RFC-3339,
+ * full-date (Y-m-d), which is what HTML5 dictates.
+ *
+ * @var string
+ */
+ protected $format = 'Y-m-d';
+
+ /**
* Retrieves a Date Validator configured for a DateTime Input type
*
* @return ValidatorInterface
10 tests/ZendTest/Form/Element/DateTest.php
View
@@ -10,6 +10,7 @@
namespace ZendTest\Form\Element;
+use DateTime;
use PHPUnit_Framework_TestCase as TestCase;
use Zend\Form\Element\Date as DateElement;
use Zend\Form\Factory;
@@ -85,4 +86,13 @@ public function testProvidesInputSpecificationThatIncludesValidatorsBasedOnAttri
}
}
}
+
+ public function testValueReturnedFromComposedDateTimeIsRfc3339FullDateFormat()
+ {
+ $element = new DateElement('foo');
+ $date = new DateTime();
+ $element->setValue($date);
+ $value = $element->getValue();
+ $this->assertEquals($date->format('Y-m-d'), $value);
+ }
}
Something went wrong with that request. Please try again.