Skip to content

Commit

Permalink
[Locale] Fix #2179 StubIntlDateFormatter support yy format
Browse files Browse the repository at this point in the history
Fix #2179 Year limit is 2031 like IntlDateFormatter
  • Loading branch information
stealth35 committed Sep 16, 2011
1 parent 9ffd8ca commit 43b55ef
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Expand Up @@ -294,6 +294,13 @@ protected function calculateUnixTimestamp(\DateTime $dateTime, array $options)
$dateTime->setTimezone(new \DateTimeZone($timezone));
}

// Normalize yy year
preg_match_all($this->regExp, $this->pattern, $matches);
if (in_array('yy', $matches[0])) {
$dateTime->setTimestamp(time());
$year = $year > $dateTime->format('y') + 20 ? 1900 + $year : 2000 + $year;
}

$dateTime->setDate($year, $month, $day);
$dateTime->setTime($hour, $minute, $second);

Expand Down
Expand Up @@ -544,8 +544,7 @@ public function parseProvider()
return array(
// years
array('y-M-d', '1970-1-1', 0),
// TODO: review to support or not this variant
// array('yy-M-d', '70-1-1', 0),
array('yy-M-d', '70-1-1', 0),

// months
array('y-M-d', '1970-1-1', 0),
Expand Down

0 comments on commit 43b55ef

Please sign in to comment.