parseWeekDay():

for the park-time-limit checking take into account that the
 	start-date-time and end-date-time are on different days.
This commit is contained in:
Gerhard Hoffmann 2024-09-03 11:15:08 +02:00
parent 75f1c1bb76
commit f02521d3c2

View File

@ -112,7 +112,7 @@ ATBWeekDay parseWeekDay(Configuration &cfg,
for (auto l = o.MemberBegin(); l != o.MemberEnd(); ++l) { for (auto l = o.MemberBegin(); l != o.MemberEnd(); ++l) {
if (l->name.IsString()) { if (l->name.IsString()) {
QString const &member = QString::fromStdString(l->name.GetString()); QString const &member = QString::fromStdString(l->name.GetString());
if (member == "default") { if (member == "prev_day_sunday?") {
if (l->value.IsArray()) { if (l->value.IsArray()) {
auto limits = l->value.GetArray(); auto limits = l->value.GetArray();
if (limits.Size() >= 2) { if (limits.Size() >= 2) {
@ -120,8 +120,10 @@ ATBWeekDay parseWeekDay(Configuration &cfg,
parking_time_limit = QTime::fromString(QString::fromStdString(limits[1].GetString()), Qt::ISODate); parking_time_limit = QTime::fromString(QString::fromStdString(limits[1].GetString()), Qt::ISODate);
} }
parkTimeLimitChecker = [&cfg, weekDay, weekDayName](ATBTariffCarryOverSettings const& cs, parkTimeLimitChecker = [&cfg, weekDay, weekDayName](ATBTariffCarryOverSettings const& cs,
QDateTime const &startTime,
QDateTime const &endTime, QDateTime const &endTime,
int paymentOptionIndex) { int paymentOptionIndex) {
if (startTime.date() < endTime.date()) { // start end end on different days
if (endTime.date().dayOfWeek() == (int)weekDay) { if (endTime.date().dayOfWeek() == (int)weekDay) {
if (endTime.time() > cs.m_parking_time_limit) { if (endTime.time() > cs.m_parking_time_limit) {
qCritical() << __func__ << ":" << __LINE__ qCritical() << __func__ << ":" << __LINE__
@ -139,6 +141,7 @@ ATBWeekDay parseWeekDay(Configuration &cfg,
cfg.getPaymentOptions(paymentOptionIndex).pop_plus_steps_saved; cfg.getPaymentOptions(paymentOptionIndex).pop_plus_steps_saved;
} }
} }
}
return false; return false;
}; };
} }
@ -151,8 +154,10 @@ ATBWeekDay parseWeekDay(Configuration &cfg,
parking_time_limit = QTime::fromString(QString::fromStdString(limits[1].GetString()), Qt::ISODate); parking_time_limit = QTime::fromString(QString::fromStdString(limits[1].GetString()), Qt::ISODate);
} }
parkTimeLimitChecker = [&cfg, weekDayName](ATBTariffCarryOverSettings const& cs, parkTimeLimitChecker = [&cfg, weekDayName](ATBTariffCarryOverSettings const& cs,
QDateTime const &startTime,
QDateTime const &endTime, QDateTime const &endTime,
int paymentOptionIndex) { int paymentOptionIndex) {
if (startTime.date() < endTime.date()) { // start end end on different days
if (previousDayHoliday(cfg, endTime)) { if (previousDayHoliday(cfg, endTime)) {
if (endTime.time() > cs.m_parking_time_limit) { if (endTime.time() > cs.m_parking_time_limit) {
qCritical() << __func__ << ":" << __LINE__ qCritical() << __func__ << ":" << __LINE__
@ -170,6 +175,7 @@ ATBWeekDay parseWeekDay(Configuration &cfg,
cfg.getPaymentOptions(paymentOptionIndex).pop_plus_steps_saved; cfg.getPaymentOptions(paymentOptionIndex).pop_plus_steps_saved;
} }
} }
}
return false; return false;
}; };
} }
@ -251,8 +257,10 @@ ATBWeekDay parseWeekDay(Configuration &cfg,
} }
parkTimeLimitChecker = [&cfg, weekDay](ATBTariffCarryOverSettings const& cs, parkTimeLimitChecker = [&cfg, weekDay](ATBTariffCarryOverSettings const& cs,
QDateTime const &startTime,
QDateTime const &endTime, QDateTime const &endTime,
int paymentOptionIndex) { int paymentOptionIndex) {
if (startTime.date() < endTime.date()) { // start end end on different days
if (endTime.date().dayOfWeek() == (int)weekDay) { if (endTime.date().dayOfWeek() == (int)weekDay) {
if (endTime.time() > cs.m_parking_time_limit) { if (endTime.time() > cs.m_parking_time_limit) {
qCritical() << __func__ << ":" << __LINE__ qCritical() << __func__ << ":" << __LINE__
@ -268,6 +276,7 @@ ATBWeekDay parseWeekDay(Configuration &cfg,
cfg.getPaymentOptions(paymentOptionIndex).pop_plus_steps_saved; cfg.getPaymentOptions(paymentOptionIndex).pop_plus_steps_saved;
} }
} }
}
return false; return false;
}; };
} else } else
@ -280,8 +289,10 @@ ATBWeekDay parseWeekDay(Configuration &cfg,
} }
} }
parkTimeLimitChecker = [&cfg](ATBTariffCarryOverSettings const& cs, parkTimeLimitChecker = [&cfg](ATBTariffCarryOverSettings const& cs,
QDateTime const &startTime,
QDateTime const &endTime, QDateTime const &endTime,
int paymentOptionIndex) { int paymentOptionIndex) {
if (startTime.date() < endTime.date()) { // start end end on different days
if (previousDayHoliday(cfg, endTime)) { if (previousDayHoliday(cfg, endTime)) {
if (endTime.time() > cs.m_parking_time_limit) { if (endTime.time() > cs.m_parking_time_limit) {
qCritical() << __func__ << ":" << __LINE__ qCritical() << __func__ << ":" << __LINE__
@ -297,6 +308,7 @@ ATBWeekDay parseWeekDay(Configuration &cfg,
cfg.getPaymentOptions(paymentOptionIndex).pop_plus_steps_saved; cfg.getPaymentOptions(paymentOptionIndex).pop_plus_steps_saved;
} }
} }
}
return false; return false;
}; };
} }
@ -1523,7 +1535,6 @@ int Configuration::getPaymentOptionIndex(PERMIT_TYPE permitType) const {
int getPaymentOptionIndex(Configuration const &cfg) { int getPaymentOptionIndex(Configuration const &cfg) {
int const numOptions = cfg.getAllPaymentOptions().size(); int const numOptions = cfg.getAllPaymentOptions().size();
for (int opt=0; opt < numOptions; ++opt) { for (int opt=0; opt < numOptions; ++opt) {