Skip to content

Commit

Permalink
...
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinDev committed Jan 27, 2022
1 parent e4742dc commit 77dff09
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/core/src/Component/EntityFilter/Filter/Date.php
Expand Up @@ -24,6 +24,7 @@ private function convertDateShortCode(string $string, ?string $locale = null): s

//$string = preg_replace('/date\([\'"]?([a-z% ]+)[\'"]?\)/i',
// strftime(strpos('\1', '%') ? '\1': '%\1'), $string);
$string = F::preg_replace_str('/date\([\'"]?%?W[\'"]?\)/i', $this->getWinterYear(), $string);
$string = F::preg_replace_str('/date\([\'"]?%?Y-1[\'"]?\)/i', date('Y', strtotime('-1 year')), $string);
$string = F::preg_replace_str('/date\([\'"]?%?Y+1[\'"]?\)/i', date('Y', strtotime('next year')), $string);
$string = F::preg_replace_str('/date\([\'"]?%?Y[\'"]?\)/i', (string) strftime('%Y'), $string);
Expand All @@ -33,6 +34,11 @@ private function convertDateShortCode(string $string, ?string $locale = null): s
return F::preg_replace_str('/date\([\'"]?%?e[\'"]?\)/i', (string) strftime('%e'), $string);
}

private function getWinterYear()
{
return date('m') < 4 ? date('Y') : date('Y', strtotime('next year'));
}

private function convertLocale(string $locale): string
{
if ('fr' == $locale) {
Expand Down

0 comments on commit 77dff09

Please sign in to comment.