diff --git a/library/include/mobilisis/tariff_carryover.h b/library/include/mobilisis/tariff_carryover.h index 72e80bd..901881e 100644 --- a/library/include/mobilisis/tariff_carryover.h +++ b/library/include/mobilisis/tariff_carryover.h @@ -61,6 +61,28 @@ struct ATBTariffCarryOver { return QString("ERROR unknown carry over application: %1").arg(static_cast(m_carryOverIf)); } + int computeMinutesUntilCarryOverEnd(QDateTime const &dt) { + int minutes = 0; + QString end = m_range.m_end.toString(Qt::ISODate); + if (end == "24:00:00") { + QDateTime t = dt.addDays(1); + t.setTime(QTime(0,0,0)); + minutes = dt.secsTo(t) / 60; + } else { + QDateTime t(dt); + t.setTime(QTime::fromString(end, Qt::ISODate)); + minutes = dt.secsTo(t) / 60; + } + + if (minutes < 0 || minutes > m_range.m_duration) { + minutes = 0; + } + + // qCritical() << __func__ << ":" << __LINE__ << "minutes" << minutes; + + return minutes; + } + friend QDebug operator<<(QDebug debug, ATBTariffCarryOver const &co) { QDebugStateSaver saver(debug);