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

Commit

Permalink
Use more user-friendly format Y-m-d instead of Y-n-j
Browse files Browse the repository at this point in the history
  • Loading branch information
bakura10 committed Aug 15, 2012
1 parent eb27880 commit 056a5ba
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
2 changes: 1 addition & 1 deletion library/Zend/Form/Element/DateSelect.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public function prepareElement(Form $form)
protected function getValidator() protected function getValidator()
{ {
if (null === $this->validator) { if (null === $this->validator) {
$this->validator = new DateValidator(array('format' => 'Y-n-j')); $this->validator = new DateValidator(array('format' => 'Y-m-d'));
} }


return $this->validator; return $this->validator;
Expand Down
20 changes: 14 additions & 6 deletions library/Zend/Form/View/Helper/FormDateSelect.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -214,12 +214,16 @@ public function getLocale()
*/ */
public function getDaysOptions($pattern) public function getDaysOptions($pattern)
{ {
$formatter = new IntlDateFormatter($this->getLocale(), null, null, null, null, $pattern); $keyFormatter = new IntlDateFormatter($this->getLocale(), null, null, null, null, 'dd');
$date = new DateTime('1970-01-01'); $valueFormatter = new IntlDateFormatter($this->getLocale(), null, null, null, null, $pattern);
$date = new DateTime('1970-01-01');


$result = array(); $result = array();
for ($day = 1; $day <= 31; $day++) { for ($day = 1; $day <= 31; $day++) {
$result[$day] = $formatter->format($date); $key = $keyFormatter->format($date);
$value = $valueFormatter->format($date);
$result[$key] = $value;

$date->modify('+1 day'); $date->modify('+1 day');
} }


Expand All @@ -234,12 +238,16 @@ public function getDaysOptions($pattern)
*/ */
public function getMonthsOptions($pattern) public function getMonthsOptions($pattern)
{ {
$formatter = new IntlDateFormatter($this->getLocale(), null, null, null, null, $pattern); $keyFormatter = new IntlDateFormatter($this->getLocale(), null, null, null, null, 'MM');
$date = new DateTime('1970-01-01'); $valueFormatter = new IntlDateFormatter($this->getLocale(), null, null, null, null, $pattern);
$date = new DateTime('1970-01-01');


$result = array(); $result = array();
for ($month = 1; $month <= 12; $month++) { for ($month = 1; $month <= 12; $month++) {
$result[$month] = $formatter->format($date); $key = $keyFormatter->format($date);
$value = $valueFormatter->format($date);
$result[$key] = $value;

$date->modify('+1 month'); $date->modify('+1 month');
} }


Expand Down
2 changes: 1 addition & 1 deletion library/Zend/Validator/Regex.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public function isValid($value)
$this->error(self::INVALID); $this->error(self::INVALID);
return false; return false;
} }
var_dump($value);
$this->setValue($value); $this->setValue($value);


$status = @preg_match($this->pattern, $value); $status = @preg_match($this->pattern, $value);
Expand Down

0 comments on commit 056a5ba

Please sign in to comment.