检查日期格式是否正确

@param string $text 日期，如：2000-01-20 或 2017/1/8
163161
public static function date($text)
	{
	    if(!preg_match("/^([\\d]+)[\\-\\/]([\\d]{1,2})[\\-\\/]([\\d]{1,2})$/", $text, $match)) {
	        return false;
	    }

	    list($_, $year, $month, $day) = $match;

	    // 001
	    if (strlen($month) > 2 || strlen($day) > 2) {
	        return false;
	    }

	    if (!checkdate($month, $day, $year)) {
	        return false;
	    }

	    return true;
	}
1202886
public function clientBeforeSend($text)
    {
        $local_part = '[\d\wа-я][\d\wа-я\.\-]*';
        $server_part = '[\d\wа-я][\d\wа-я\-\.]+\.(\w{2,}|рф)';
        if ($this->settings['href_method'] != 'none')
        {
            preg_match_all('/<a\s+.*href="mailto:([^"]+)"(.*)>/ui', $text, $matches,
                PREG_OFFSET_CAPTURE | PREG_SET_ORDER);
            $delta = 0;
            for ($i = 0; $i < count($matches); $i++)
            {
                $replace = $this->encodeHref($matches[$i][1][0]);
                $text = substr_replace($text, $replace, $matches[$i][1][1] + $delta,
                    strlen($matches[$i][1][0]));
                $delta += strlen($replace) - strlen($matches[$i][1][0]);
            }
        }
        if ($this->settings['text_method'] != 'none')
        {
            preg_match_all('/(mailto:)?' . $local_part . '@' . $server_part . '/ui', $text, $matches,
                PREG_OFFSET_CAPTURE | PREG_SET_ORDER);
            $delta = 0;
            for ($i = 0; $i < count($matches); $i++)
            {
                if (strpos($matches[$i][0][0], 'mailto:') === false)
                {
                    $replace = $this->encodeText($matches[$i][0][0]);
                    $text = substr_replace($text, $replace, $matches[$i][0][1] + $delta,
                        strlen($matches[$i][0][0]));
                    $delta += strlen($replace) - strlen($matches[$i][0][0]);
                }
            }
        }
        return $text;
    }
781852
public static function Parse($text)
	{
		$text = strtoupper( trim( $text ) );

		$result = preg_match( "/^(?<sign>-?)(?<year>\d{4,4})-(?<month>\d{1,2})(?<offset>(?=[+\-a-zA-Z])(([+\-]\d{2}(:\d{2}))|Z|((\?!-|\\+)(?i)[^0-9].{3,})))?$/i", $text, $matches );
		if ( ! $result )
		{
			throw XPath2Exception::withErrorCodeAndParams( "FORG0001", Resources::FORG0001, array( $text, "xs:gYear" ) );
		}

		$error =	empty( $matches['year'] ) ||
					( CoreFuncs::$strictGregorian && $matches['year'] < 1532 ) ||
					empty( $matches['month'] ) ||
					$matches['month'] > 12 ||
					$matches['month'] < 1;

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

			if ( ! $error && ! is_null( $offsetMatches ) )
			{
				$error = empty( $offsetMatches['hours'] ) || $offsetMatches['hours'] > 14 ||
						 empty( $offsetMatches['minutes'] ) || $offsetMatches['minutes'] > 59;
			}

		}

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

		/**
		 * @var bool $s
		 */
	    $s = SchemaTypes::startsWith( $text, "-" );
		if ( $s ) $text = substr( $text, 1 );
		$dateTime = \DateTime::createFromFormat( "!Y-mO", $text );
		if ( $dateTime )
	        return new GYearMonthValue( $s, $dateTime );

		$dateTime = \DateTime::createFromFormat( "!Y-m\Z", $text );
		if ( $dateTime )
	        return new GYearMonthValue( $s, $dateTime );

		$dateTime = \DateTime::createFromFormat( "!Y-m", $text );
		if ( $dateTime )
	        return new GYearMonthValue( $s, $dateTime );

        throw XPath2Exception::withErrorCodeAndParams( "FORG0001", Resources::FORG0001, array( $text, "GYearMonth" ) );
	}
1276893
function filterText( $text )
    {
        $text = str_replace('\\','\\\\',$text);
        $text = str_replace('(','\(',$text);
        $text = str_replace(')','\)',$text);
        $text = str_replace('&lt;','<',$text);
        $text = str_replace('&gt;','>',$text);
        $text = str_replace('&#039;','\'',$text);
        $text = str_replace('&quot;','"',$text);
        $text = str_replace('&amp;','&',$text);

        return $text;
    }
196984
private function _checkSilenced($text) {
		if ($this->_isActive('checkSilencedError')) {
			if (!$this->_config->isException('checkSilencedError', $text)) {
				$previousToken = $this->tokenizer->peekPrvsToken();
				if ($previousToken->id === T_AROBAS) {
					$this->_writeError('checkSilencedError', $this->_getMessage('SILENCED_ERROR'));
				}
			}
		}
	}
1359986
public function match($text)
    {
        return false !== strpos($this->name, $text) || false !== strpos($this->email, $text);
    }
5556
private function setStartFromText($text) {
        if ($this->starting_text === null) {
            // If we have a forced table at the start, we get that one...
            if (is_array($text)) {
                if (is_array($text[0])) {
                    // Code like array(array(ENCODING, ''))
                    $this->starting_text = $this->METHOD[$text[0][0]];
                    return;
                } else {
                    if (is_string($text[0])) {
                        // Code like array('test') (Automatic text)
                        $text = $text[0];
                    } else {
                        // Code like array(ENCODING, '')
                        $this->starting_text = $this->METHOD[$text[0]];
                        return;
                    }
                }
            }

            // At this point, we had an "automatic" table selection...
            // If we can get at least 4 numbers, go in C; otherwise go in B.
            $tmp = preg_quote($this->keysC, '/');
            $length = strlen($text);
            if ($length >= 4 && preg_match('/[' . $tmp . ']/', substr($text, 0, 4))) {
                $this->starting_text = 'C';
            } else {
                if ($length > 0 && strpos($this->keysB, $text[0]) !== false) {
                    $this->starting_text = 'B';
                } else {
                    $this->starting_text = 'A';
                }
            }
        }
    }
9076
protected function processBuildTime(string &$content): void
    {
        $pattern = $this->getTagPattern('build_time');
        $content = preg_replace_callback($pattern, function ($match) {
            return '<?php /*模板编译于' . date('Y-m-d H:i:s') . '*/ ?>';
        }, $content);
    }
3844
public function filter(&$text)
    {
        $matches = array();
        if(preg_match_all('#<ktml:content(.*)>#siU', $text, $matches))
        {
            foreach($matches[1] as $key => $match) {
                $text = str_replace($matches[0][$key], $this->getTemplate()->content(), $text);
            }
        }
    }
59058
protected function replaceInText($text)
	{
		$text = str_replace("##YEAR##", date('Y'), $text);
		$text = str_replace("##DATE##", date('Y-m-d'), $text);

		return $text;
	}
1176987
public static function removeAccents($text){
    static $diac;
    return strtr(
      utf8_decode($text),
      $diac ? $diac : $diac = utf8_decode('àáâãäçèéêëìíîïñòóôõöùúûüýÿÀÁÂÃÄÇÈÉÊËÌÍÎÏÑÒÓÔÕÖÙÚÛÜÝ'),
      'aaaaaceeeeiiiinooooouuuuyyAAAAACEEEEIIIINOOOOOUUUUY');
  }
132293
public function setDate($t = null)
    {
        if ($t > 0) {
            $this->setText(date('Y-m-d H:i', $t));
        } else {
            $this->setText("");
        }
    }
84390
private function _checkWhiteSpaceBefore($text) {
		if ($this->_isActive('checkWhiteSpaceBefore')) {

			if (!$this->_config->isException('checkWhiteSpaceBefore', $text)) {

				if (!$this->tokenizer->checkPreviousToken(T_WHITESPACE)) {
					$msg = $this->_getMessage('SPACE_BEFORE_TOKEN', $text);
					$this->_writeError('checkWhiteSpaceBefore', $msg);
				}
			}
		}
	}
601431
protected function onSetText(string $text): void
    {
        parent::onSetText($text);

        $this->isInvalid = false;
        $this->value = null;

        if ($this->hasError()) {
            return;
        }

        if ($this->isEmpty()) {
            return;
        }

        $this->value = Url::tryParse($text);

        if ($this->value === null) {
            $this->setError('Invalid value');
            $this->isInvalid = true;
        }
    }
934221
public function updateProgress($text) {
		$text = self::format($text);
		if($this->progressValue) {
			$len = strlen($this->progressValue);
			fwrite(STDOUT, "\033[{$len}D");
		}
		$this->progressValue = $text;

		fwrite(STDOUT, $this->progressValue);
	}
383981
public function heading($text) {
        $this->info('');
        $this->info('===================');
        $this->info($text);
        $this->info('===================');
        $this->info('');
    }
299708
protected function info($text)
    {
        if($this->console) {
            $this->console->info($text);
        }

        if($this->logger) {
            $this->logger->info($text);
        }
    }