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
514c3cc4
Commit
514c3cc4
authored
Mar 21, 2021
by
David Faure
Browse files
Add support for "whitsun +1 day", should be "easter +50 days"
This is just in case, I haven't actually seen this in the wild.
parent
019eef28
Pipeline
#56232
passed with stage
in 22 seconds
Changes
4
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
autotests/parsertest.cpp
View file @
514c3cc4
...
...
@@ -44,6 +44,7 @@ private Q_SLOTS:
T
(
"easter +1 day off"
);
T
(
"easter -2 days off"
);
T2
(
"whitsun off"
,
"easter +49 days off"
);
T2
(
"whitsun +1 day off"
,
"easter +50 days off"
);
T
(
"2020"
);
T
(
"2020-2021"
);
T
(
"1970-2022/2"
);
...
...
src/lib/openinghoursparser.y
View file @
514c3cc4
...
...
@@ -668,7 +668,7 @@ MonthdayRangeAdditional:
| DateFrom[D] DateOffset[O] {
$$ = new MonthdayRange;
$$->begin = $D;
$$->begin.offset = $O;
$$->begin.offset
+
= $O;
$$->end = $$->begin;
}
| DateFrom[F] RangeSeparator DateTo[T] {
...
...
@@ -681,7 +681,7 @@ MonthdayRangeAdditional:
| DateFrom[F] DateOffset[OF] RangeSeparator DateTo[T] {
$$ = new MonthdayRange;
$$->begin = $F;
$$->begin.offset = $OF;
$$->begin.offset
+
= $OF;
$$->end = $T;
if ($$->end.year == 0) { $$->end.year = $$->begin.year; }
if ($$->end.month == 0) { $$->end.month = $$->begin.month; }
...
...
@@ -692,7 +692,7 @@ MonthdayRangeAdditional:
$$->end = $T;
if ($$->end.year == 0) { $$->end.year = $$->begin.year; }
if ($$->end.month == 0) { $$->end.month = $$->begin.month; }
$$->end.offset = $OT;
$$->end.offset
+
= $OT;
}
| DateFrom[F] RangeSeparator T_MONTH[M] AltMonthdayOffset[O] {
$$ = new MonthdayRange;
...
...
@@ -707,11 +707,11 @@ MonthdayRangeAdditional:
| DateFrom[F] DateOffset[OF] RangeSeparator DateTo[T] DateOffset[OT] {
$$ = new MonthdayRange;
$$->begin = $F;
$$->begin.offset = $OF;
$$->begin.offset
+
= $OF;
$$->end = $T;
if ($$->end.year == 0) { $$->end.year = $$->begin.year; }
if ($$->end.month == 0) { $$->end.month = $$->begin.month; }
$$->end.offset = $OT;
$$->end.offset
+
= $OT;
}
;
...
...
src/lib/selectors.cpp
View file @
514c3cc4
...
...
@@ -296,6 +296,18 @@ bool DateOffset::operator==(DateOffset other) const
return
weekday
==
other
.
weekday
&&
nthWeekday
==
other
.
nthWeekday
&&
dayOffset
==
other
.
dayOffset
;
}
DateOffset
&
DateOffset
::
operator
+=
(
DateOffset
other
)
{
// Only dayOffset really supports += (this is for whitsun)
dayOffset
+=
other
.
dayOffset
;
// The others can't possibly be set already
Q_ASSERT
(
weekday
==
0
);
Q_ASSERT
(
nthWeekday
==
0
);
weekday
=
other
.
weekday
;
nthWeekday
=
other
.
nthWeekday
;
return
*
this
;
}
bool
Date
::
operator
==
(
Date
other
)
const
{
if
(
variableDate
!=
other
.
variableDate
)
...
...
src/lib/selectors_p.h
View file @
514c3cc4
...
...
@@ -176,6 +176,7 @@ class DateOffset
{
public:
bool
operator
==
(
DateOffset
other
)
const
;
DateOffset
&
operator
+=
(
DateOffset
other
);
int16_t
dayOffset
;
int8_t
weekday
;
...
...
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