Fixes the calendar in constructor to handle null
This commit is contained in:
parent
af81c8cfad
commit
43f26727d0
@ -134,7 +134,7 @@ class IntlDateFormatter
|
||||
* @param int $timetype Type of time formatting, one of the format type constants
|
||||
* @param mixed $timezone Timezone identifier
|
||||
* @param int $calendar Calendar to use for formatting or parsing. The only currently
|
||||
* supported value is IntlDateFormatter::GREGORIAN.
|
||||
* supported value is IntlDateFormatter::GREGORIAN (or null using the default calendar, i.e. "GREGORIAN")
|
||||
* @param string $pattern Optional pattern to use when formatting
|
||||
*
|
||||
* @see http://www.php.net/manual/en/intldateformatter.create.php
|
||||
@ -149,7 +149,7 @@ class IntlDateFormatter
|
||||
throw new MethodArgumentValueNotImplementedException(__METHOD__, 'locale', $locale, 'Only the locale "en" is supported');
|
||||
}
|
||||
|
||||
if (self::GREGORIAN !== $calendar) {
|
||||
if (self::GREGORIAN !== $calendar && null !== $calendar) {
|
||||
throw new MethodArgumentValueNotImplementedException(__METHOD__, 'calendar', $calendar, 'Only the GREGORIAN calendar is supported');
|
||||
}
|
||||
|
||||
|
@ -28,6 +28,12 @@ class IntlDateFormatterTest extends AbstractIntlDateFormatterTest
|
||||
$this->assertEquals('y-M-d', $formatter->getPattern());
|
||||
}
|
||||
|
||||
public function testConstructorWithoutCalendar()
|
||||
{
|
||||
$formatter = new IntlDateFormatter('en', IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT, 'UTC', null, 'y-M-d');
|
||||
$this->assertEquals('y-M-d', $formatter->getPattern());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException
|
||||
*/
|
||||
|
Reference in New Issue
Block a user