public function testUnclosedFormat() { $this->setExpectedException(InvalidArgumentException::class, 'Wrong formatted date, missing ]'); $formatter = IntlDateTimeFormatter::createWithFlagDateTime(); $formatter->format(new DateTime('2015-10-16 15:37:00'), '[[ Hallo [Y', 'en_US', null); }
/** * @param DOMElement[] $value * @param string $picture * @param null $language * @return string * @throws InvalidArgumentException */ public static function formatDateTime($value, $picture, $language = null) { Assert::assertArray($value); Assert::assertSchema($value[0], 'dateTime'); if (self::$dateTimeFormatter === null) { // @codeCoverageIgnoreStart if (extension_loaded('intl')) { self::$dateTimeFormatter = Functions\Formatter\IntlDateTimeFormatter::createWithFlagDateTime(); } else { self::$dateTimeFormatter = Functions\Formatter\DateTimeFormatter::createWithFlagDateTime(); } // @codeCoverageIgnoreEnd } if ($language === null) { $locale = self::detectSystemLocale(); } else { $locale = $language; } $date = DateTime::createFromFormat(XsDateTime::FORMAT, $value[0]->nodeValue); return self::$dateTimeFormatter->format($date, $picture, $locale, 'AD'); }