Commits ------- 43b55ef [Locale] Fix #2179 StubIntlDateFormatter support yy format Discussion ---------- [Locale] Fix #2179 StubIntlDateFormatter support yy format Fix #2179 Year limit is 2031 like IntlDateFormatter
@@ -294,6 +294,13 @@ class FullTransformer
$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);
@@ -544,8 +544,7 @@ class StubIntlDateFormatterTest extends LocaleTestCase
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