/**
  * 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;
 }
 protected function getIntlErrorCode()
 {
     return IntlGlobals::getErrorCode();
 }
Exemple #3
0
 /**
  * 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();
 }
 /**
  * Stub implementation for the {@link intl_get_error_code()} function of the
  * intl extension.
  *
  * @author Bernhard Schussek <*****@*****.**>
  *
  * @return bool The error code of the last intl function call or
  *              IntlGlobals::U_ZERO_ERROR if no error occurred.
  *
  * @see IntlGlobals::getErrorCode()
  */
 function intl_get_error_code()
 {
     return IntlGlobals::getErrorCode();
 }