Date filter

@param string $value
@param string $argument
@return string
355536
private function filterDate($value, $argument = null)
    {
        if ($argument) {
            $value = date($argument, strtotime($value));
        }

        return $value;
    }
1046176
public function filter($value)
    {
        if (!is_scalar($value) && !is_array($value)) {
            return $value;
        }

        // a unicode safe way of converting characters to \x00\x00 notation
        $pregQuotedSeparator = preg_quote($this->separator, '#');

        if (StringUtils::hasPcreUnicodeSupport()) {
            $patterns = [
                '#(' . $pregQuotedSeparator.')(\P{Z}{1})#u',
                '#(^\P{Z}{1})#u',
            ];
            if (!extension_loaded('mbstring')) {
                $replacements = [
                    function ($matches) {
                        return strtoupper($matches[2]);
                    },
                    function ($matches) {
                        return strtoupper($matches[1]);
                    },
                ];
            } else {
                $replacements = [
                    function ($matches) {
                        return mb_strtoupper($matches[2], 'UTF-8');
                    },
                    function ($matches) {
                        return mb_strtoupper($matches[1], 'UTF-8');
                    },
                ];
            }
        } else {
            $patterns = [
                '#(' . $pregQuotedSeparator.')([\S]{1})#',
                '#(^[\S]{1})#',
            ];
            $replacements = [
                function ($matches) {
                    return strtoupper($matches[2]);
                },
                function ($matches) {
                    return strtoupper($matches[1]);
                },
            ];
        }

        $filtered = $value;
        foreach ($patterns as $index => $pattern) {
            $filtered = preg_replace_callback($pattern, $replacements[$index], $filtered);
        }
        return $filtered;
    }
1034488
public function filterByValueLike($value)
    {
        $callback = function (BindingInterface $binding, $key) use ($value) {
            return strpos($binding->getValue(), $value) !== false;
        };

        return $this->filter($callback);
    }
1119969
protected function dateBefore($value, $arg, $not = true)
    {
        if (!($value <= $arg) && $not) {
            $this->addReturn('date_before_or_equal', 'before', [ ':datebefore' => $arg ]);
        } elseif (($value <= $arg) && !$not) {
            $this->addReturn('date_before_or_equal', 'not_before', [ ':datebefore' => $arg ]);
        }
    }
669176
public function formatDate($value)
	{
		return $this->getLocale()->dateFormatter->formatDateTime($this->normalizeDateValue($value), $this->dateFormat, null);
	}
260937
public function filter($value)
    {
        if (!is_string($value)) {
            return $value;
        }

        // Strip unicode bombs, and make sure all newlines are UNIX newlines.
        $value = preg_replace('{^\xEF\xBB\xBF|\x1A}', '', $value);
        $value = preg_replace('{\r\n?}', "\n", $value);

        $lambda = function($text) {
            $text = htmlspecialchars($text, ENT_COMPAT, 'UTF-8');
            /** @noinspection NotOptimalRegularExpressionsInspection */
            $text = preg_replace('/--/', '&mdash;', $text);
            $text = nl2br($text, false);
            $text = sprintf('<p>%s</p>', $text);

            return $text;
        };

        $paragraphs = preg_split('/\n{2,}/', $value, -1, PREG_SPLIT_NO_EMPTY);
        $paragraphs = array_map($lambda, $paragraphs);

        return implode("\n\n", $paragraphs);
    }
98010
protected function setArgumentValue($argv, $argument, $key, $value)
    {
        // Arguments are given the value true if they only need to
        // be defined on the command line to be set.
        if ($argument->noValue()) {
            $argument->setValue(true);
            return $argv;
        }

        if (is_null($value)) {
            if (count($argv) === 0) {
                return $argv;
            }

            // If the value wasn't previously defined in "key=value"
            // format then define it from the next command argument.
            $nextArgvValue = $argv[$key + 1];
            if ($this->isValidArgumentValue($nextArgvValue)) {
                $argument->setValue($nextArgvValue);
                unset($argv[$key + 1]);
                return $argv;
            }
        }

        $argument->setValue($value);

        return $argv;
    }
347215
public function filter($value)
    {
        $params = (array) $this->options['callback_params'];
        array_unshift($params, $value);

        return call_user_func_array($this->options['callback'], $params);
    }
33400
protected function filter($key, $value, $arg)
    {
        if (!is_string($value)) {
            throw new \InvalidArgumentException(htmlspecialchars(
                "The $key field does not exist"
            ));
        }

        return htmlspecialchars($value);
    }
1131273
public function twigVicDateFormatFilter($value, $format = 'F j, Y H:i', $timezone = null)
    {
        try {
            $result = twig_date_format_filter($this->twig, $value, $format, $timezone);
        } catch (\Exception $e) {
            return $value;
        }

        return $result;
    }
842024
protected function filterable($value)
    {
        if (count($value) !== $this->expectedInputs) {
            throw new Exception\RuntimeException(
                sprintf(
                    'There are not enough values in the array to filter this date (Required: %d, Received: %d)',
                    $this->expectedInputs,
                    count($value)
                )
            );
        }
    }
665730
static public function toDate($value=null)
    {
        if (!$value) {
            return date('Y-m-d');
        } else {
            if(is_numeric($value)) {
                // strftime format is different from date()
                //$value = strftime('%Y-%m-%d %H:%M:%S', $value);
                $value = strftime('%Y-%m-%d', $value);
            }
            
            return $value;
        }
    }
15260
public function filter($value) {
    	    	
    	$value   = str_replace(["\r", "\r\n", "\n"], '', $value);
    	$decoded = json_decode($value,true);
    	if(is_null($decoded)){
    		return null;
    	}    	
    	
    	switch($this->options["format"]){
    	    case self::DECODED:
    	        return $decoded;
    	    case self::JSON:
    	        return $value;
    	    case self::SERIALIZED:
    	        return serialize($decoded);
    	    default:
    	        throw new FilterException("unknown format for JSON filter specified");
    	}
    }
838411
public function filter_datetime($v, $p)
    {
        if (is_bool($p) && $p) {
            $p = 'Y-m-d H:i:s';
        }
        $dt = \date_create_from_format($p, $v->getValue());
        if (!$dt) {
            $v->setValue(null);
            $v->setError(__METHOD__, $p);
            return;
        }
        $v->setValue($dt->format($p));
    }
935155
public function filter($value)
    {
        if (!is_scalar($value)) {
            return $value;
        }
        $value = (string) $value;

        return basename($value);
    }
362000
protected function filterValue($value)
    {
        $filter = new Filter();

        call_user_func($this->callable, $filter);

        return $filter->filter($value);
    }
546290
public function filter($value)
    {
        if (!is_string($value) && !is_array($value)) {
            return $value;
        }
        $result = @preg_replace($this->search, $this->replacement, $value);
        if ($result === null) {
            throw new FilterErrorException('An error occurred executing RegexReplace filter');
        }

        return $result;
    }