Parse RFC850's date format

@access protected
@return int Timestamp
518534
public function date_rfc850($date)
	{
		static $pcre;
		if (!$pcre)
		{
			$space = '[\x09\x20]+';
			$day_name = $this->day_pcre;
			$month = $this->month_pcre;
			$day = '([0-9]{1,2})';
			$year = $hour = $minute = $second = '([0-9]{2})';
			$zone = '([A-Z]{1,5})';
			$pcre = '/^' . $day_name . ',' . $space . $day . '-' . $month . '-' . $year . $space . $hour . ':' . $minute . ':' . $second . $space . $zone . '$/i';
		}
		if (preg_match($pcre, $date, $match))
		{
			/*
			Capturing subpatterns:
			1: Day name
			2: Day
			3: Month
			4: Year
			5: Hour
			6: Minute
			7: Second
			8: Timezone
			*/

			// Month
			$month = $this->month[strtolower($match[3])];

			// Character timezone
			if (isset($this->timezone[strtoupper($match[8])]))
			{
				$timezone = $this->timezone[strtoupper($match[8])];
			}
			// Assume everything else to be -0000
			else
			{
				$timezone = 0;
			}

			// Deal with 2 digit year
			if ($match[4] < 50)
			{
				$match[4] += 2000;
			}
			else
			{
				$match[4] += 1900;
			}

			return gmmktime($match[5], $match[6], $match[7], $month, $match[2], $match[4]) - $timezone;
		}
		else
		{
			return false;
		}
	}
382725
private function parseTextFile()
    {
        $data = file($this->inputTextFile);

        $timeZoneMap = array();

        foreach ($data as $line) {
            // Remove \n
            $line = str_replace(array("\n", "\r"), '', $line);
            $line = trim($line);

            if (strlen($line) == 0 || substr($line, 0, 1) == '#') {
                continue;
            }
            if (strpos($line, '|')) {
                // Valid line
                $parts = explode('|', $line);


                $prefix = $parts[0];
                $timezone = $parts[1];

                $timeZoneMap[$prefix] = $timezone;
            }
        }

        return $timeZoneMap;
    }
2136
private function getRFC1123DateString() {
        $date = new \DateTime(null, new \DateTimeZone("UTC"));
        return str_replace("+0000", "GMT", $date->format(\DateTime::RFC1123));
    }
1261072
public function readUNBDateTimeOfPreparation()
    {
        // separate date (YYMMDD) and time (HHMM)
        $date = $this->readEdiDataValue('UNB', 4, 0);
        if (!empty($date)) {
            $time = $this->readEdiDataValue('UNB', 4, 1);
            $datetime = \preg_replace('#(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)#', '20$1-$2-$3 $4:$5:00', $date . $time);

            return $datetime;
        }

        // common YYYYMMDDHHMM
        $datetime = $this->readEdiDataValue('UNB', 4);
        $datetime = \preg_replace('#(\d\d\d\d)(\d\d)(\d\d)(\d\d)(\d\d)#', '$1-$2-$3 $4:$5:00', $datetime);

        return $datetime;
    }
280559
public function getBadPasswordDate()
    {
        if ($timestamp = $this->getBadPasswordTimestamp()) {
            return (new DateTime())->setTimestamp($timestamp)->format($this->dateFormat);
        }
    }
957326
protected function _parseTimestamp($timestamp)
    {
        if (is_null($timestamp))
            return AbstractQuery::getCurrentTimestamp();

        if (!AbstractQuery::isValidTimestamp($timestamp)) {
            if ($sTime = strtotime($timestamp)) {
                $timestamp = date('YmdHis', $sTime);
            } else {
                throw oxNew(
                    ConsoleException::class,
                    'Invalid timestamp format, use YYYYMMDDhhmmss format'
                );
            }
        }

        return $timestamp;
    }
416789
public function parseSummaryReport()
    {

        $reports = [ ];

        preg_match_all(
            "/^\s*".
            "(?<ip>[a-f0-9:\.]+)\s+".
            "(?<date>\w+\s+\d+\s\d+)h\/".
            "(?<days>\d+)\s+".
            "(?<trap>\d+)\s+".
            "(?<user>\d+)\s+".
            "(?<mole>\d+)\s+".
            "(?<simp>\d+)".
            "/m",
            $this->parsedMail->getMessageBody(),
            $matches,
            PREG_SET_ORDER
        );

        if (is_array($matches) && count($matches) > 0) {
            foreach ($matches as $match) {
                $report = [
                    'Source-IP' => $match['ip'],
                    'Received-Date' => $match['date'] . ':00',
                    'Duration-Days' => $match['days'],
                ];
                foreach (['trap', 'user', 'mole', 'simp'] as $field) {
                    $report[ucfirst($field) ."-Report"] = $match[$field];
                }

                $reports[] = $report;
            }
        }

        return $reports;
    }
35916
public static function getTimestamp()
	{
		$curl	= new Net_CURL( self::$url );
		$result	= $curl->exec();
		$status	= $curl->getStatus();
		if( $status['http_code'] != 200 )
			throw new Exception( "Service URL is not reachable." );
		$parts	= explode( "\n", $result );
		$date	= trim( $parts[2] );
		$time	= strtotime( $date );
		return $time;
	}
685374
public function getPHPDateTimePattern()
    {
        $isoFormat = Calendar::getDateTimeFormat('short');
        $result = Calendar::tryConvertIsoToPhpFormat($isoFormat);
        if ($result === null) {
            $result = t(/*i18n: Short date/time format: see http://www.php.net/manual/en/function.date.php */ 'n/j/Y g.i A');
        }

        return $result;
    }
1220388
private function parseDateTimeFormat()
    {
        try {
            if ($this->isNull($this->format)) {
                $this->format = self::$defaultFormat;
            }

            $str = new StringObject($this->format);
            $chunks = $str->split();

            $this->buildFormatterList();

            foreach ($chunks as $c) {
                foreach (self::$formatters as $fk => $f) {
                    if ($f->inArray($c)) {
                        $this->dateTimeFormat[$fk] = $c;
                    }
                }
            }
            $this->dateTimeFormat = new ArrayObject($this->dateTimeFormat);
        } catch (\Exception $e) {
            throw new DateTimeObjectException(DateTimeObjectException::MSG_INVALID_DATE_FORMAT, [$this->format]);
        }
    }
499892
final public function time() {
		if ($this->dbtype == 'pgsql')
			return $this->query(
				"SELECT EXTRACT('epoch' from CURRENT_TIMESTAMP) AS now"
			)['now'];
		if ($this->dbtype == 'mysql')
			return $this->query(
				"SELECT UNIX_TIMESTAMP() AS now")['now'];
		return $this->query(
			"SELECT strftime('%s', CURRENT_TIMESTAMP) AS now"
		)['now'];
	}
117959
public function readDate()
    {
        $dateReference = $this->readInteger();
        if (($dateReference & 0x01) == 0) {
            $dateReference = $dateReference >> 1;
            if ($dateReference>=count($this->_referenceObjects)) {
                require_once 'Zend/Amf/Exception.php';
                throw new Zend_Amf_Exception('Undefined date reference: ' . $dateReference);
            }
            return $this->_referenceObjects[$dateReference];
        }

        $timestamp = floor($this->_stream->readDouble() / 1000);

        require_once 'Zend/Date.php';
        $dateTime  = new Zend_Date($timestamp);
        $this->_referenceObjects[] = $dateTime;
        return $dateTime;
    }
87420
protected function parseTransactionEntryTimestamp()
    {
        $results = [];
        if (preg_match('/^:60F:[C|D]([\d]{6})/m', $this->getCurrentStatementData(), $results) && !empty($results[1])) {
            return $this->sanitizeTimestamp($results[1]);
        }

        return 0;
    }
601904
function getmicrotime() {
		if (function_exists('gettimeofday')) {
			$tod = gettimeofday();
			$sec = $tod['sec'];
			$usec = $tod['usec'];
		} else {
			$sec = time();
			$usec = 0;
		}
		return strftime('%Y-%m-%d %H:%M:%S', $sec) . '.' . sprintf('%06d', $usec);
	}
64361
public function getUpdatedAtTimestamp(): ?int
    {
        if (!$this->hasUpdatedAt()) {
            return null;
        }

        $timestamp = strtotime($this->getUpdatedAt() . 'UTC');

        if ($timestamp === false) {
        	throw new Exception("Unable to get timestamp from \"{$this->getUpdatedAt()}\"");
        }

        return $timestamp;
    }
129602
public function getFormattedDateRangeDate() {

    // Load session instance date range date values.
    $timestamp = $this->get('timestamp')->value;
    $year_start = date('Y', $timestamp);
    $month_day_start = date('M j', $timestamp);
    $timestamp_to = $this->get('timestamp_to')->value;
    $year_to = date('Y', $timestamp_to);
    $month_day_to = date('M j', $timestamp_to);

    // Format date range to eliminate repeated values.
    if ($year_start == $year_to) {
      if (date('M', $timestamp) == date('M', $timestamp_to)) {
        if ($month_day_start == $month_day_to) {
          // M j, Y.
          $formatted_date = "$month_day_start, $year_start";
        }
        else {
          // M j - j, Y.
          $day_to = date('j', $timestamp_to);
          $formatted_date =  "$month_day_start - $day_to, $year_start";
        }
      }
      else {
        // M j - M j, Y.
        $formatted_date =  "$month_day_start - $month_day_to, $year_start";
      }
    }
    else {
      // M j, Y - M j, Y.
      $formatted_date = $month_day_start . ", $year_start - " . $month_day_to . ", $year_to";
    }

    return $formatted_date;
  }
1059327
public function getTimestamp(): int
    {
        $supportedClasses = implode(
            ', ',
            [
                '\MongoTimestamp',
                '\MongoDate',
                '\MongoDB\BSON\Timestamp',
                '\MongoDB\BSON\UTCDateTime',
                '\DateTimeInterface',
            ]
        );

        if (!$this->t || !is_object($this->t)) {
            throw new \DomainException(
                'The timestamp to normalise must be one of ' . $supportedClasses . ' but it is not an object'
            );
        }

        switch (get_class($this->t)) {
            case 'MongoTimestamp':
                return (int) $this->t->__toString();

            case 'MongoDate':
                return $this->t->sec;

            case 'MongoDB\BSON\Timestamp':
                return $this->t->getTimestamp();

            case 'MongoDB\BSON\UTCDateTime':
                return (int) $this->t->toDateTime()->format('U');
        }

        if ($this->t instanceof \DateTimeInterface) {
            return $this->t->getTimestamp();
        }

        throw new \DomainException(
            'The normalised timestamp must be one of ' . $supportedClasses
        );
    }