Whether the date condition is met
@param array $condition
@return boolean
164853
public function current(array $condition)
    {
        $value = strtotime(reset($condition['value']));
        return empty($value) ? false : $this->compare(GC_TIME, $value, $condition['operator']);
    }
681718
public static function isDate($date): bool
    {
        if (!\preg_match('/^([\d]{4})-((?:0?[\d])|(?:1[0-2]))-((?:0?[\d])|(?:[1-2][\d])|(?:3[01]))( [\d]{2}:[\d]{2}:[\d]{2})?$/',
            $date, $matches)) {
            return false;
        }

        return \checkdate((int)$matches[2], (int)$matches[3], (int)$matches[1]);
    }
409687
public function every( $condition ) {
		$response = true;

		foreach ( $this->elements as $element ) {
			$result = call_user_func( $condition, $element );

			if ( false === $result ) {
				$response = false;
				break;
			}
		}

		return $response;
	}
989375
public function contains(Date $date) : bool
    {
        return $this->start->comesBeforeOrEqual($date) && $this->end->comesAfterOrEqual($date);
    }
24352
public static function dateEquals($val, $date): bool
    {
        if (!$val || (!$time = \strtotime($val))) {
            return false;
        }

        return $date ? $time === \strtotime((string)$date) : false;
    }
944464
public function setLength(array $condition)
    {
        if (is_array($condition) === true)  {
            $this->{key($condition)} = (int) current($condition);
        }

        return $this;
    }
904731
public function parseCondition($condition) {
        $condition = str_ireplace(array_keys($this->comparison),array_values($this->comparison),$condition);
        $condition = preg_replace('/\$(\w+):(\w+)\s/is','$\\1->\\2 ',$condition);
        switch(strtolower(C('TMPL_VAR_IDENTIFY'))) {
            case 'array': // 识别为数组
                $condition  =   preg_replace('/\$(\w+)\.(\w+)\s/is','$\\1["\\2"] ',$condition);
                break;
            case 'obj':  // 识别为对象
                $condition  =   preg_replace('/\$(\w+)\.(\w+)\s/is','$\\1->\\2 ',$condition);
                break;
            default:  // 自动判断数组或对象 只支持二维
                $condition  =   preg_replace('/\$(\w+)\.(\w+)\s/is','(is_array($\\1)?$\\1["\\2"]:$\\1->\\2) ',$condition);
        }
        if(false !== strpos($condition, '$Think'))
            $condition      =   preg_replace_callback('/(\$Think.*?)\s/is', array($this, 'parseThinkVar'), $condition);        
        return $condition;
    }
62856
private function prepareCondition(array $condition): array
    {
        if ($condition['sql'] instanceof self) {
            list($sql, $params) = $condition['sql']->toSql();

            $condition['sql'] = $sql ? '(' . $sql . ')' : null;

            $condition['params'] = $params;
        }

        if ($condition['sql'] instanceof WhereClauseStrategy) {
            list($sql, $params) = $condition['sql']->whereToSql(false);

            $condition['sql'] = $sql ? '(' . $sql . ')' : null;

            $condition['params'] = $params;
        }

        if ($condition['sql'] instanceof HavingClauseStrategy) {
            list($sql, $params) = $condition['sql']->havingToSql(false);

            $condition['sql'] = $sql ? '(' . $sql . ')' : null;

            $condition['params'] = $params;
        }

        return $condition;
    }
363566
public function order(array $condition, array $data)
    {
        $is_order = (int) isset($data['order_id']);
        $value = (int) filter_var(reset($condition['value']), FILTER_VALIDATE_BOOLEAN);
        return $this->compare($is_order, $value, $condition['operator']);
    }
550593
protected function isDatePartKeysProvided(array $source)
    {
        return isset($source['day']) && ctype_digit($source['day'])
            && isset($source['month']) && ctype_digit($source['month'])
            && isset($source['year']) && ctype_digit($source['year']);
    }
1142958
public function route(array $condition)
    {
        if (!in_array($condition['operator'], array('=', '!='))) {
            return false;
        }

        $route = $this->route->get();
        return $this->compare($route['pattern'], $condition['value'], $condition['operator']);
    }
607333
public function any($condition)
    {
        $this->filter($condition);

        $tmp = new \stdClass();

        return $this->getFirst($tmp) !== $tmp;
    }
733615
protected function resolveConditionalLogic($condition)
    {
        if (is_callable([ $this, $condition ])) {
            return !!$this->{$condition}();
        } elseif (is_callable($condition)) {
            return !!$condition();
        } elseif ($this->form()->obj()->view()) {
            return !!$this->form()->obj()->renderTemplate($condition);
        }

        return !!$condition;
    }
1322298
private function isExpired(array $document) : bool
    {
        return isset($document[MongoDBCache::EXPIRATION_FIELD]) &&
            $document[MongoDBCache::EXPIRATION_FIELD] instanceof MongoDate &&
            $document[MongoDBCache::EXPIRATION_FIELD]->sec < time();
    }
1269149
public function validateCondition($condition)
    {
        $is_boolean = true;
        if (!empty($condition)) {
            $encapsuledElements = array();
            preg_match_all(
                KeywordableTraitInterface::GET_BALANCED_BRACKETS,
                $condition,
                $encapsuledElements
            );
            if (count($encapsuledElements[0]) > 0) {
                foreach ($encapsuledElements[0] as $key => $encapsuledElement) {
                    $is_boolean = (preg_match(KeywordableTraitInterface::IS_AND_BOOLEAN, $encapsuledElements[1][$key]) ||
                        preg_match(KeywordableTraitInterface::IS_OR_BOOLEAN, $encapsuledElements[1][$key])) &&
                        $is_boolean;
                    $condition = preg_replace('/'.preg_quote($encapsuledElement).'/', '##', $condition, 1);
                    if (count($encapsuledElements[0]) > 0) {
                        $is_boolean = $is_boolean  && $this->validateCondition($condition);
                    }
                }
            } else {
                $is_boolean = (preg_match(KeywordableTraitInterface::IS_AND_BOOLEAN, $condition) ||
                    preg_match(KeywordableTraitInterface::IS_OR_BOOLEAN, $condition)) &&
                    $is_boolean;
            }
        }

        return $is_boolean;
    }
979377
public function filterOne(array $condition)
	{
		foreach ($this->data as $item) {
			foreach ($condition as $key => $value) {
				if ($item[$key] == $value) {
					$this->setData([$item]);

					return $this;
				}
			}
		}

		$this->setData([]);

		return $this;
	}
778057
protected function count_while_true( $condition ) {
		$count = 0;

		foreach ( $this->elements as $element ) {
			if ( ! $condition($element) ) {
				break;
			}
			$count++;
		}

		return $count;
	}