Commit 514c3cc4 authored by David Faure's avatar 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
......@@ -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");
......
......@@ -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;
}
;
......
......@@ -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)
......
......@@ -176,6 +176,7 @@ class DateOffset
{
public:
bool operator==(DateOffset other) const;
DateOffset &operator+=(DateOffset other);
int16_t dayOffset;
int8_t weekday;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment