Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
facets_date_range_picker
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
facets_date_range_picker
Commits
a78d5111
Commit
a78d5111
authored
3 years ago
by
Tim Diels
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3282126
by tim-diels, cimo75: Add long weekend option
parent
2914ae47
Branches
Branches containing commit
Tags
1.0.0-beta3
Tags containing commit
1 merge request
!4
Issue #3282126: Make the starting day for the weekend dependent on the regional settings
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/Plugin/facets/processor/DateRangePickerProcessor.php
+2
-1
2 additions, 1 deletion
src/Plugin/facets/processor/DateRangePickerProcessor.php
src/Plugin/facets/query_type/SearchApiDateRangePicker.php
+28
-0
28 additions, 0 deletions
src/Plugin/facets/query_type/SearchApiDateRangePicker.php
with
30 additions
and
1 deletion
src/Plugin/facets/processor/DateRangePickerProcessor.php
+
2
−
1
View file @
a78d5111
...
...
@@ -42,7 +42,8 @@ class DateRangePickerProcessor extends DatePickerProcessorBase implements BuildP
'#options'
=>
[
'today'
=>
$this
->
t
(
'Today'
),
'tomorrow'
=>
$this
->
t
(
'Tomorrow'
),
'this_weekend'
=>
$this
->
t
(
'This weekend'
),
'this_weekend'
=>
$this
->
t
(
'This weekend (Sat to Sun)'
),
'this_weekend_long'
=>
$this
->
t
(
'This weekend (Fri to Sun)'
),
'next_seven_days'
=>
$this
->
t
(
'Next 7 days'
),
'next_fourteen_days'
=>
$this
->
t
(
'Next 14 days'
),
'next_thirty_days'
=>
$this
->
t
(
'Next 30 days'
),
...
...
This diff is collapsed.
Click to expand it.
src/Plugin/facets/query_type/SearchApiDateRangePicker.php
+
28
−
0
View file @
a78d5111
...
...
@@ -119,6 +119,29 @@ class SearchApiDateRangePicker extends SearchApiDateRangePickerBase {
}
break
;
case
'this_weekend_long'
:
// Today is friday.
if
(
$now
->
format
(
'N'
)
===
'5'
)
{
$start_date
=
$now
;
$end_date
=
$now
->
modify
(
'+2 days'
);
}
elseif
(
$now
->
format
(
'N'
)
===
'6'
)
{
$start_date
=
$now
;
$end_date
=
$now
->
modify
(
'+1 day'
);
}
// Today is sunday.
elseif
(
$now
->
format
(
'N'
)
===
'7'
)
{
$start_date
=
$now
;
$end_date
=
$now
->
modify
(
'-1 day'
);
}
// Today is just a weekday.
else
{
$start_date
=
new
DrupalDateTime
(
'next friday'
,
'UTC'
);
$end_date
=
new
DrupalDateTime
(
'next sunday'
,
'UTC'
);
}
break
;
case
'next_seven_days'
:
$start_date
=
new
DrupalDateTime
(
'now'
,
'UTC'
);
$end_date
=
new
DrupalDateTime
(
'+7 days'
,
'UTC'
);
...
...
@@ -189,6 +212,10 @@ class SearchApiDateRangePicker extends SearchApiDateRangePickerBase {
$display
=
$this
->
t
(
'This weekend'
);
break
;
case
'this_weekend_long'
:
$display
=
$this
->
t
(
'This long weekend'
);
break
;
case
'next_seven_days'
:
$display
=
$this
->
t
(
'Next 7 days'
);
break
;
...
...
@@ -219,6 +246,7 @@ class SearchApiDateRangePicker extends SearchApiDateRangePickerBase {
'today'
,
'tomorrow'
,
'this_weekend'
,
'this_weekend_long'
,
'next_seven_days'
,
'next_fourteen_days'
,
'next_thirty_days'
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment