Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Libraries
KOpeningHours
Commits
405c78dd
Commit
405c78dd
authored
Dec 05, 2021
by
David Faure
Browse files
Simplify "Feb 1-29" to "Feb"
BUG: 446252
parent
9bb6be75
Pipeline
#105632
passed with stage
in 40 seconds
Changes
4
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
autotests/parsertest.cpp
View file @
405c78dd
...
...
@@ -366,6 +366,9 @@ private Q_SLOTS:
T3
(
"Sa-Mo 10:00-23:00, Th 10:00-23:00"
,
"Sa-Mo 10:00-23:00, Th 10:00-23:00"
,
"Sa-Mo,Th 10:00-23:00"
);
// beginDay > endDay
T3
(
"Sa-Mo 10:00-23:00, Fr 10:00-23:00"
,
"Sa-Mo 10:00-23:00, Fr 10:00-23:00"
,
"Fr-Mo 10:00-23:00"
);
// beginDay > endDay
T3
(
"Su-Th 10:00-23:00, Fr-Sa 10:00-23:00"
,
"Su-Th 10:00-23:00, Fr-Sa 10:00-23:00"
,
"Mo-Su 10:00-23:00"
);
// beginDay > endDay
T3
(
"Feb 1-Feb 29 Mo-Su 10:30-20:30; Aug 1-Aug 31 Mo-Fr 10:30-12:00; PH closed"
,
"Feb 01-29 Mo-Su 10:30-20:30; Aug 01-31 Mo-Fr 10:30-12:00; PH closed"
,
"Feb Mo-Su 10:30-20:30; Aug Mo-Fr 10:30-12:00; PH closed"
);
// complex or creative 24/7 use
T
(
"06:00-01:00 open
\"
Dining in
\"
|| 24/7
\"
Drive-through
\"
"
);
...
...
src/lib/openinghours.cpp
View file @
405c78dd
...
...
@@ -194,6 +194,9 @@ void OpeningHoursPrivate::simplify()
if
(
rule
->
m_weekdaySelector
)
{
rule
->
m_weekdaySelector
->
simplify
();
}
if
(
rule
->
m_monthdaySelector
)
{
rule
->
m_monthdaySelector
->
simplify
();
}
}
}
...
...
src/lib/selectors.cpp
View file @
405c78dd
...
...
@@ -454,6 +454,24 @@ QByteArray MonthdayRange::toExpression(const MonthdayRange &prev) const
return
expr
;
}
void
MonthdayRange
::
simplify
()
{
// "Feb 1-29" => "Feb" (#446252)
if
(
begin
.
variableDate
==
Date
::
FixedDate
&&
end
.
variableDate
==
Date
::
FixedDate
&&
begin
.
year
==
end
.
year
&&
begin
.
month
&&
end
.
month
&&
begin
.
month
==
end
.
month
&&
begin
.
day
&&
end
.
day
)
{
// The year doesn't matter, but take one with a leap day, for Feb 1-29
const
int
lastDay
=
QDate
{
2004
,
end
.
month
,
end
.
day
}.
daysInMonth
();
if
(
begin
.
day
==
1
&&
end
.
day
==
lastDay
)
{
begin
.
day
=
0
;
end
.
day
=
0
;
}
}
}
int
YearRange
::
requiredCapabilities
()
const
{
return
Capability
::
None
;
...
...
src/lib/selectors_p.h
View file @
405c78dd
...
...
@@ -215,6 +215,7 @@ public:
int
requiredCapabilities
()
const
;
SelectorResult
nextInterval
(
const
Interval
&
interval
,
const
QDateTime
&
dt
,
OpeningHoursPrivate
*
context
)
const
;
QByteArray
toExpression
(
const
MonthdayRange
&
prev
)
const
;
void
simplify
();
Date
begin
=
{
0
,
0
,
0
,
Date
::
FixedDate
,
{
0
,
0
,
0
}
};
Date
end
=
{
0
,
0
,
0
,
Date
::
FixedDate
,
{
0
,
0
,
0
}
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment