示例#1
0
 public function testJanuaryFirst2017Name()
 {
     $formatter = IntlDateTimeFormatter::createWithFlagDate();
     $this->assertSame('01-01-2017', $formatter->format(new \DateTime('2017-01-01 18:42:34.000000', new \DateTimeZone('UTC')), '[D]-[MNn]-[Y]', 'nl_NL', null));
 }
示例#2
0
 /**
  * @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');
 }