当前位置: 首页>>代码示例>>PHP>>正文


PHP Globals\IntlGlobals类代码示例

本文整理汇总了PHP中Symfony\Component\Intl\Globals\IntlGlobals的典型用法代码示例。如果您正苦于以下问题:PHP IntlGlobals类的具体用法?PHP IntlGlobals怎么用?PHP IntlGlobals使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了IntlGlobals类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: calculateUnixTimestamp

 /**
  * Calculates the Unix timestamp based on the matched values by the reverse matching regular
  * expression of parse().
  *
  * @param \DateTime $dateTime The DateTime object to be used to calculate the timestamp
  * @param array     $options  An array with the matched values to be used to calculate the timestamp
  *
  * @return bool|int The calculated timestamp or false if matched date is invalid
  */
 protected function calculateUnixTimestamp(\DateTime $dateTime, array $options)
 {
     $options = $this->getDefaultValueForOptions($options);
     $year = $options['year'];
     $month = $options['month'];
     $day = $options['day'];
     $hour = $options['hour'];
     $hourInstance = $options['hourInstance'];
     $minute = $options['minute'];
     $second = $options['second'];
     $marker = $options['marker'];
     $timezone = $options['timezone'];
     // If month is false, return immediately (intl behavior)
     if (false === $month) {
         IntlGlobals::setError(IntlGlobals::U_PARSE_ERROR, 'Date parsing failed');
         return false;
     }
     // Normalize hour
     if ($hourInstance instanceof HourTransformer) {
         $hour = $hourInstance->normalizeHour($hour, $marker);
     }
     // Set the timezone if different from the default one
     if (null !== $timezone && $timezone !== $this->timezone) {
         $dateTime->setTimezone(new \DateTimeZone($timezone));
     }
     // Normalize yy year
     preg_match_all($this->regExp, $this->pattern, $matches);
     if (in_array('yy', $matches[0])) {
         $dateTime->setTimestamp(time());
         $year = $year > $dateTime->format('y') + 20 ? 1900 + $year : 2000 + $year;
     }
     $dateTime->setDate($year, $month, $day);
     $dateTime->setTime($hour, $minute, $second);
     return $dateTime->getTimestamp();
 }
开发者ID:Dren-x,项目名称:mobit,代码行数:44,代码来源:FullTransformer.php

示例2: parse

 /**
  * Parse string to a timestamp value.
  *
  * @param string $value    String to convert to a time value
  * @param int    $position Not supported. Position at which to start the parsing in $value (zero-based).
  *                         If no error occurs before $value is consumed, $parse_pos will
  *                         contain -1 otherwise it will contain the position at which parsing
  *                         ended. If $parse_pos > strlen($value), the parse fails immediately.
  *
  * @return string Parsed value as a timestamp
  *
  * @see http://www.php.net/manual/en/intldateformatter.parse.php
  *
  * @throws MethodArgumentNotImplementedException When $position different than null, behavior not implemented
  */
 public function parse($value, &$position = null)
 {
     // We don't calculate the position when parsing the value
     if (null !== $position) {
         throw new MethodArgumentNotImplementedException(__METHOD__, 'position');
     }
     $dateTime = $this->createDateTime(0);
     $transformer = new FullTransformer($this->getPattern(), $this->getTimeZoneId());
     $timestamp = $transformer->parse($dateTime, $value);
     // behave like the intl extension. FullTransformer::parse() set the proper error
     $this->errorCode = IntlGlobals::getErrorCode();
     $this->errorMessage = IntlGlobals::getErrorMessage();
     return $timestamp;
 }
开发者ID:tahermarkos,项目名称:Transport,代码行数:29,代码来源:IntlDateFormatter.php

示例3: resetError

 /**
  * Set the error to the default U_ZERO_ERROR.
  */
 protected function resetError()
 {
     IntlGlobals::setError(IntlGlobals::U_ZERO_ERROR);
     $this->errorCode = IntlGlobals::getErrorCode();
     $this->errorMessage = IntlGlobals::getErrorMessage();
 }
开发者ID:nuwe1,项目名称:symfony,代码行数:9,代码来源:NumberFormatter.php

示例4: isIntlFailure

 protected function isIntlFailure($errorCode)
 {
     return IntlGlobals::isFailure($errorCode);
 }
开发者ID:lamzin-andrey,项目名称:skyengtt.loc,代码行数:4,代码来源:IntlDateFormatterTest.php

示例5:

 /**
  * Stub implementation for the {@link intl_error_name()} function of the intl
  * extension.
  *
  * @param int $errorCode The error code.
  *
  * @return string The name of the error code constant.
  *
  * @see IntlGlobals::getErrorName()
  */
 function intl_error_name($errorCode)
 {
     return IntlGlobals::getErrorName($errorCode);
 }
开发者ID:BusinessCookies,项目名称:CoffeeMachineProject,代码行数:14,代码来源:functions.php

示例6: getIntlErrorName

 protected function getIntlErrorName($errorCode)
 {
     return IntlGlobals::getErrorName($errorCode);
 }
开发者ID:BusinessCookies,项目名称:CoffeeMachineProject,代码行数:4,代码来源:IntlGlobalsTest.php


注:本文中的Symfony\Component\Intl\Globals\IntlGlobals类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。