Skip to content

Commit

Permalink
[ENH] add future weeks to DateFilterType
Browse files Browse the repository at this point in the history
  • Loading branch information
n3o77 committed Mar 14, 2024
1 parent fd402fe commit 236440f
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/FilterType/DateFilterType.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,13 @@ public static function getVariables(): array
],
'WEEKS' => [
'ONE_WEEK_AGO' => 'ONE_WEEK_AGO',
'NEXT_WEEK' => 'IN_NEXT_WEEK',
'TWO_WEEKS_AGO' => 'TWO_WEEKS_AGO',
'IN_TWO_WEEKS' => 'IN_TWO_WEEKS',
'THREE_WEEKS_AGO' => 'THREE_WEEKS_AGO',
'IN_THREE_WEEKS' => 'IN_THREE_WEEKS',
'FOUR_WEEKS_AGO' => 'FOUR_WEEKS_AGO',
'IN_FOUR_WEEKS' => 'IN_FOUR_WEEKS',
],
'MONDAYS_WEEKS' => [
'START_OF_WEEK_MONDAY' => 'START_OF_WEEK_MONDAY',
Expand Down Expand Up @@ -203,15 +207,27 @@ public function replaceVarsInValue(string $value, array $options = []): string
case 'ONE_WEEK_AGO':
return $now->subWeek()->startOfDay()->toFormattedDateString();

case 'NEXT_WEEK':
return $now->addWeek()->startOfDay()->toFormattedDateString();

case 'TWO_WEEKS_AGO':
return $now->subWeeks(2)->startOfDay()->toFormattedDateString();

case 'IN_TWO_WEEKS':
return $now->addWeeks(2)->startOfDay()->toFormattedDateString();

case 'THREE_WEEKS_AGO':
return $now->subWeeks(3)->startOfDay()->toFormattedDateString();

case 'IN_THREE_WEEKS':
return $now->addWeeks(3)->startOfDay()->toFormattedDateString();

case 'FOUR_WEEKS_AGO':
return $now->subWeeks(4)->startOfDay()->toFormattedDateString();

case 'IN_FOUR_WEEKS_AGO':
return $now->addWeeks(4)->startOfDay()->toFormattedDateString();

case 'START_OF_WEEK_MONDAY':
return $now->startOfWeek(CarbonImmutable::MONDAY)->toFormattedDateString();

Expand Down

0 comments on commit 236440f

Please sign in to comment.