public function testInvalidPicture() { $formatter = IntlDateTimeFormatter::createWithFlagTime(); try { $this->assertEquals('09:37:00', $formatter->format(new DateTime('2015-10-16'), '[Y]]', 'en_US', null)); } catch (InvalidArgumentException $e) { $this->assertEquals('XTDE1340', $e->getErrorCode()); } }
/** * @param DOMElement[] $value * @param string $picture * @param null $language * @return string * @throws InvalidArgumentException */ public static function formatTime($value, $picture, $language = null) { Assert::assertArray($value); Assert::assertSchema($value[0], 'time'); if (self::$timeFormatter === null) { // @codeCoverageIgnoreStart if (extension_loaded('intl')) { self::$timeFormatter = Functions\Formatter\IntlDateTimeFormatter::createWithFlagTime(); } else { self::$timeFormatter = Functions\Formatter\DateTimeFormatter::createWithFlagTime(); } // @codeCoverageIgnoreEnd } if ($language === null) { $locale = self::detectSystemLocale(); } else { $locale = $language; } $date = DateTime::createFromFormat(XsTime::FORMAT, $value[0]->nodeValue); return self::$timeFormatter->format($date, $picture, $locale, 'AD'); }