Parse
@param string $text
@return TimeValue
192316
public static function Parse( $text )
	{
		$text = CoreFuncs::NormalizeSpace( $text );

		// $x = "-2016-01-02T09:08:02.1234Z";
		// $x = "-2016-01-02";
		// $x = "-2016-01-02T09:08:02";
		// $x = "-2016-01-02T09:08";
		// $x = "-2016-01-02T09";
		$pattern = "^((?<time>(?<hour>[0-9]{1,2})(:(?<minute>[0-9]{1,2}))?(:(?<second>[0-9]{2,2}))?)(\.(?<micro>[0-9]+))?)?(?<offset>(?=[+\-a-zA-Z]).*)?$";

		$result = preg_match( "/$pattern/", $text, $matches );
		$error = empty( $text ) || ! $result ||
				( ! empty( $matches['offset'] ) && $matches['offset'] == $text ) ||
				( empty( $matches['minute'] ) && empty( $matches['second'] ) ) ||
				( ! empty( $matches['hour'] )   && ( $matches['hour'] > 24 ) ) ||
				( ! empty( $matches['minute'] ) && ( $matches['minute'] > 59 ) ) ||
				( ! empty( $matches['second'] ) && ( $matches['second'] > 59 ) ) ||
				( ! empty( $matches['offset'] ) && ! preg_match( "/^[+-]?\d+$|^[+-]?\d{2}:\d{2}$|^[a-z]+$/i", $matches['offset'] ) );

		if ( ! $error )
		{
			$timeSeconds = ( empty( $matches['hour'] ) ? 0 : $matches['hour'] * 3600 ) +
			( empty( $matches['minute'] ) ? 0 : $matches['minute'] * 60 ) +
			( empty( $matches['second'] ) ? 0 : $matches['second'] * 1 ) +
			( empty( $matches['micro'] ) ? 0 : $matches['micro'] / 1000 );
			$error = $timeSeconds > 86400;

			if ( ! $error && ! empty( $matches['offset'] ) && preg_match( "/^[+-](?<hours>\d{2})(:(?<minutes>\d{2}))?$/", $matches['offset'], $offsetMatches ) )
			{
				$error = ( ! empty( $offsetMatches['hours'] ) && $offsetMatches['hours'] > 14 ) ||
				empty( $offsetMatches['minutes'] ) ||
				$offsetMatches['minutes'] > 59;
			}
		}

		if ( $error )
		{
			throw XPath2Exception::withErrorCodeAndParams( "FORG0001", Resources::FORG0001, array( $text, "Date" ) );
		}

		$sign = empty( $matches['sign'] ) ? false : $matches['sign'] == "-" ;
		$date = empty( $matches['date'] ) ? "1970-01-01" : $matches['date'];
		$time = empty( $matches['time'] ) ? "" : $matches['time'];
		$offset = empty( $matches['offset'] ) ? "" : $matches['offset'];

		$microseconds = empty( $matches['micro'] ) ? 0 : $matches['micro'];
		$notlocal = ! empty( $matches['offset'] );

		$T = $date && $time ? "T" : "";

		/**
		 * @var DateTime $dateTime
		 */
		$dateTime = new \DateTime( "{$date}$T{$time}$offset" );
		$dateTime->microseconds = $microseconds;

		return new TimeValue( $dateTime, $notlocal );
	}
313670
private function parseGs1128($text) {
        /* We format correctly what the user gives */
        if (is_array($text)) {
            $formatArray = array();
            foreach ($text as $content) {
                if (is_array($content)) { /* double array */
                    if (count($content) === 2) {
                        if (is_array($content[self::ID]) || is_array($content[self::CONTENT])) {
                            throw new CINParseException('gs1128', 'Double arrays can\'t contain arrays.');
                        } else {
                            $formatArray[] = '(' . $content[self::ID] . ')' . $content[self::CONTENT];
                        }
                    } else {
                        throw new CINParseException('gs1128', 'Double arrays must contain 2 values.');
                    }
                } else { /* simple array */
                    $formatArray[] = $content;
                }
            }

            unset($text);
            $text = $formatArray;
        } else { /* string */
            $text = array($text);
        }

        $textCount = count($text);
        for ($cmpt = 0; $cmpt < $textCount; $cmpt++) {
            /* We parse the content of the array */
            if (!$this->parseContent($text[$cmpt])) {
                return;
            }
        }

        return $this->formatGs1128();
    }
933128
def parse_datetime(self, text):
        ''''''
        return parse_datetime(text, date_format=self.date_format,
                              is_day_period=self.is_day_period)
711619
static function parse($text)
    {
        $parser = new \Parsedown();

        $text = static::cleanLeadingSpace($text);

        return $parser->text($text);
    }
541092
public function purge($text)
    {
        foreach ($this->parsers as $parser) {
            $text = $parser->purge($text);
        }

        return $text;
    }
923609
public function parse($text)
    {
        if (empty($text)) {
            return '';
        }

        return $this->driver->text(
            static::removeLeadingWhitespace($this->escape($text))
        );
    }
124890
private function processText($text)
    {
        // verify if content is a string otherwhise just return the original provided content
        if (!is_string($text) || empty($text)) {
            return $text;
        }
        // find all tags based on the REGEX expression
        preg_match_all(static::REGEX, $text, $results, PREG_SET_ORDER);
        // foreach all the results matches the regex
        foreach ($results as $row) {
            // When value is empty (can be caused by using `link[]` we have to skip this item.
            if (empty($row['value'])) {
                continue;
            }
            // extract tag name from regex
            $tag = $row['function'];
            if ($this->hasTag($tag)) {
                $replace = $this->parseTag($tag, $row);
                $text = preg_replace('/'.preg_quote($row[0], '/').'/mi', $replace, $text, 1);
            }
        }
        
        return $text;
    }
789583
public function parse($text) {
      $this->queue = array();
      $this->parser = xml_parser_create();        
      $this->parsed = 0;     
      $this->opened = 0;
      xml_set_object($this->parser, $this);
      xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0);
      xml_parser_set_option($this->parser, XML_OPTION_SKIP_WHITE, 1);
      $code = xml_parse_into_struct($this->parser, $text, $vals, $index); 
      /**
       * Parse into bAML
       * type structure
       * 
       */ 
      if ($code != 0) {
        return XMLUtility::Make($this, $vals); 
      }
        
      throw new \CatapultApiException("Provided text was not valid XMLUtility..");
    }
1195715
def _parse(text, **options):
    
    # Handling special cases
    if text == "now":
        return pendulum.now()

    parsed = base_parse(text, **options)

    if isinstance(parsed, datetime.datetime):
        return pendulum.datetime(
            parsed.year,
            parsed.month,
            parsed.day,
            parsed.hour,
            parsed.minute,
            parsed.second,
            parsed.microsecond,
            tz=parsed.tzinfo or options.get("tz", UTC),
        )

    if isinstance(parsed, datetime.date):
        return pendulum.date(parsed.year, parsed.month, parsed.day)

    if isinstance(parsed, datetime.time):
        return pendulum.time(
            parsed.hour, parsed.minute, parsed.second, parsed.microsecond
        )

    if isinstance(parsed, _Interval):
        if parsed.duration is not None:
            duration = parsed.duration

            if parsed.start is not None:
                dt = pendulum.instance(parsed.start, tz=options.get("tz", UTC))

                return pendulum.period(
                    dt,
                    dt.add(
                        years=duration.years,
                        months=duration.months,
                        weeks=duration.weeks,
                        days=duration.remaining_days,
                        hours=duration.hours,
                        minutes=duration.minutes,
                        seconds=duration.remaining_seconds,
                        microseconds=duration.microseconds,
                    ),
                )

            dt = pendulum.instance(parsed.end, tz=options.get("tz", UTC))

            return pendulum.period(
                dt.subtract(
                    years=duration.years,
                    months=duration.months,
                    weeks=duration.weeks,
                    days=duration.remaining_days,
                    hours=duration.hours,
                    minutes=duration.minutes,
                    seconds=duration.remaining_seconds,
                    microseconds=duration.microseconds,
                ),
                dt,
            )

        return pendulum.period(
            pendulum.instance(parsed.start, tz=options.get("tz", UTC)),
            pendulum.instance(parsed.end, tz=options.get("tz", UTC)),
        )

    if CDuration and isinstance(parsed, CDuration):
        return pendulum.duration(
            years=parsed.years,
            months=parsed.months,
            weeks=parsed.weeks,
            days=parsed.days,
            hours=parsed.hours,
            minutes=parsed.minutes,
            seconds=parsed.seconds,
            microseconds=parsed.microseconds,
        )

    return parsed
254056
static public function parseText($text)
    {
        $text = (string)$text;
        // links
        $text = preg_replace('@(https?://([-\w\.]+)+(/([\w/_\.]*(\?\S+)?(#\S+)?)?)?)@', '<a href="$1">$1</a>', $text);
        // users         
        $text = preg_replace('(@([a-zA-Z0-9_]+))', '<a href="http://www.twitter.com/\1">\0</a>', $text);
        // hastag
        $text = preg_replace(
            '/(^|\s)#(\w*[a-zA-Z_]+\w*)/',
            '\1<a href="http://search.twitter.com/search?q=%23\2">#\2</a>',
            $text
        );

        return $text;
    }
580921
public function parse(string $text) : bool
    {
        $lower = strtolower($text);
        if (! in_array($lower, array_merge(self::TRUE_VALUES, self::FALSE_VALUES)))
            throw new ParseException($this, $text, 0, self::PARSE_ERROR);
        return in_array($lower, self::TRUE_VALUES);
    }
925955
public function read(&$text)
    {
        $text = str_replace(
            array_keys($this->_alias_read),
            array_values($this->_alias_read),
            $text);

        return $this;
    }
1026100
def _parse_ftp_time(cls, time_text):
        # type: (Text) -> Optional[int]
        
        try:
            tm_year = int(time_text[0:4])
            tm_month = int(time_text[4:6])
            tm_day = int(time_text[6:8])
            tm_hour = int(time_text[8:10])
            tm_min = int(time_text[10:12])
            tm_sec = int(time_text[12:14])
        except ValueError:
            return None
        epoch_time = calendar.timegm(
            (tm_year, tm_month, tm_day, tm_hour, tm_min, tm_sec)
        )
        return epoch_time
1177539
protected function parseAttributes($text)
    {
        // decode attribute values
        $text = htmlspecialchars_decode($text, ENT_QUOTES);

        $attributes = [];
        // attributes pattern
        $pattern = '/(\w+)\s*=\s*"([^"]*)"(?:\s|$)|(\w+)\s*=\s*\'([^\']*)\'(?:\s|$)|(\w+)\s*=\s*([^\s\'"]+)(?:\s|$)|"([^"]*)"(?:\s|$)|(\S+)(?:\s|$)/';
        // Match
        if (preg_match_all($pattern, preg_replace('/[\x{00a0}\x{200b}]+/u', " ", $text), $match, PREG_SET_ORDER)) {
            foreach ($match as $m) {
                if (!empty($m[1])) {
                    $attributes[strtolower($m[1])] = stripcslashes($m[2]);
                } elseif (!empty($m[3])) {
                    $attributes[strtolower($m[3])] = stripcslashes($m[4]);
                } elseif (!empty($m[5])) {
                    $attributes[strtolower($m[5])] = stripcslashes($m[6]);
                } elseif (isset($m[7]) && strlen($m[7])) {
                    $attributes[] = stripcslashes($m[7]);
                } elseif (isset($m[8])) {
                    $attributes[] = stripcslashes($m[8]);
                }
            }
        } else {
            $attributes = ltrim($text);
        }

        // return attributes
        return is_array($attributes) ? $attributes : [$attributes];
    }
39876
def parse_datetime(text):
    

    text = text.strip().lower()

    INPUT_FORMATS = (
        '%Y-%m-%d %H:%M:%S',
        '%Y-%m-%d %H:%M',
        '%Y-%m-%d',
        '%m/%d/%Y %H:%M:%S',
        '%m/%d/%Y %H:%M',
        '%m/%d/%Y',
        '%m/%d/%y %H:%M:%S',
        '%m/%d/%y %H:%M',
        '%m/%d/%y',
    )
    for format in INPUT_FORMATS:
        try:
            return datetime.datetime(*time.strptime(text, format)[:6])
        except ValueError:
            pass

    # Try descriptive texts
    if text == 'tomorrow':
        future = datetime.datetime.now() + datetime.timedelta(days=1)
        args = future.timetuple()[:3] + (23, 59, 59)
        return datetime.datetime(*args)
    elif text == 'today':
        return datetime.datetime(*datetime.datetime.today().timetuple()[:3])
    elif text == 'now':
        return datetime.datetime.now()
    elif text == 'yesterday':
        past = datetime.datetime.now() - datetime.timedelta(days=1)
        return datetime.datetime(*past.timetuple()[:3])
    else:
        days = 0
        matched = re.match(
            r'^((?P<weeks>\d+) ?w(eeks?)?)? ?((?P<days>\d+) ?d(ays?)?)?$', text)
        if matched:
            groupdict = matched.groupdict()
            if groupdict['days']:
                days += int(matched.groupdict()['days'])
            if groupdict['weeks']:
                days += int(matched.groupdict()['weeks']) * 7
            past = datetime.datetime.now() - datetime.timedelta(days=days)
            return datetime.datetime(*past.timetuple()[:3])

    raise ValueError('Wrong date: "%s"' % text)
1217571
public static function parse(string $string): TimeInterface
    {
        $bits = explode(":", $string);

        $seconds = (int) array_pop($bits);

        $minutes = (int) array_pop($bits);
        $seconds += ($minutes * 60);

        $hours = (int) array_pop($bits);
        $seconds += ($hours * 60 * 60);

        return new self($seconds);
    }
835886
public function parse(string $input): \DateInterval
    {
        $input = trim($this->normalizer->normalize($input));

        $definition = Pattern::DEFINE . Pattern::INTEGER . Pattern::TIME_PART . ')';
        $expression = $definition . Pattern::INTERVAL_ONLY;

        if (preg_match($expression, $input, $matches)) {
            return \DateInterval::createFromDateString($input);
        }

        throw new FormatException("Given string is not a valid time interval.");
    }