Exemplo n.º 1
0
 /**
  * @param DOMElement[] $value
  * @param string $picture
  * @return string
  * @throws InvalidArgumentException
  */
 public static function formatDateTime($value, $picture)
 {
     Assert::assertArray($value);
     Assert::assertSchema($value[0], 'dateTime');
     $date = DateTimeImmutable::createFromFormat(XsDateTime::FORMAT, $value[0]->nodeValue);
     return self::formatEvaluatedDateTime($date, $picture, self::FLAG_DATE + self::FLAG_TIME);
 }
Exemplo n.º 2
0
Arquivo: Date.php Projeto: Samshal/xsl
 /**
  * @param $value
  * @return XsInteger
  * @throws \Genkgo\Xsl\Xpath\Exception\InvalidArgumentException
  */
 public static function secondsFromDateTime($value)
 {
     Assert::assertArray($value);
     Assert::assertSchema($value[0], 'dateTime');
     return new XsInteger((int) (new DateTimeImmutable($value[0]->nodeValue))->format('s'));
 }
Exemplo n.º 3
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');
 }
Exemplo n.º 4
0
Arquivo: Text.php Projeto: Samshal/xsl
 /**
  * @param $elements
  * @return DOMDocument
  */
 public static function inScopePrefixes($elements)
 {
     Assert::assertArray($elements);
     $listOfPrefixes = [];
     foreach ($elements as $element) {
         $listOfPrefixes = array_merge($listOfPrefixes, array_keys(FetchNamespacesFromNode::fetch($element)));
     }
     return XsSequence::fromArray($listOfPrefixes);
 }