Skip to content
This repository
Browse code

Use more user-friendly format Y-m-d instead of Y-n-j

  • Loading branch information...
commit 056a5ba9b5793a58ab3842bf21fb2cca158e0b6a 1 parent eb27880
Michaël Gallego authored August 15, 2012
2  library/Zend/Form/Element/DateSelect.php
@@ -195,7 +195,7 @@ public function prepareElement(Form $form)
195 195
     protected function getValidator()
196 196
     {
197 197
         if (null === $this->validator) {
198  
-            $this->validator = new DateValidator(array('format' => 'Y-n-j'));
  198
+            $this->validator = new DateValidator(array('format' => 'Y-m-d'));
199 199
         }
200 200
 
201 201
         return $this->validator;
20  library/Zend/Form/View/Helper/FormDateSelect.php
@@ -214,12 +214,16 @@ public function getLocale()
214 214
      */
215 215
     public function getDaysOptions($pattern)
216 216
     {
217  
-        $formatter  = new IntlDateFormatter($this->getLocale(), null, null, null, null, $pattern);
218  
-        $date       = new DateTime('1970-01-01');
  217
+        $keyFormatter   = new IntlDateFormatter($this->getLocale(), null, null, null, null, 'dd');
  218
+        $valueFormatter = new IntlDateFormatter($this->getLocale(), null, null, null, null, $pattern);
  219
+        $date           = new DateTime('1970-01-01');
219 220
 
220 221
         $result = array();
221 222
         for ($day = 1; $day <= 31; $day++) {
222  
-            $result[$day] = $formatter->format($date);
  223
+            $key   = $keyFormatter->format($date);
  224
+            $value = $valueFormatter->format($date);
  225
+            $result[$key] = $value;
  226
+
223 227
             $date->modify('+1 day');
224 228
         }
225 229
 
@@ -234,12 +238,16 @@ public function getDaysOptions($pattern)
234 238
      */
235 239
     public function getMonthsOptions($pattern)
236 240
     {
237  
-        $formatter  = new IntlDateFormatter($this->getLocale(), null, null, null, null, $pattern);
238  
-        $date       = new DateTime('1970-01-01');
  241
+        $keyFormatter   = new IntlDateFormatter($this->getLocale(), null, null, null, null, 'MM');
  242
+        $valueFormatter = new IntlDateFormatter($this->getLocale(), null, null, null, null, $pattern);
  243
+        $date           = new DateTime('1970-01-01');
239 244
 
240 245
         $result = array();
241 246
         for ($month = 1; $month <= 12; $month++) {
242  
-            $result[$month] = $formatter->format($date);
  247
+            $key   = $keyFormatter->format($date);
  248
+            $value = $valueFormatter->format($date);
  249
+            $result[$key] = $value;
  250
+
243 251
             $date->modify('+1 month');
244 252
         }
245 253
 
2  library/Zend/Validator/Regex.php
@@ -118,7 +118,7 @@ public function isValid($value)
118 118
             $this->error(self::INVALID);
119 119
             return false;
120 120
         }
121  
-var_dump($value);
  121
+
122 122
         $this->setValue($value);
123 123
 
124 124
         $status = @preg_match($this->pattern, $value);

0 notes on commit 056a5ba

Please sign in to comment.
Something went wrong with that request. Please try again.