Remove m_start member.

Add defualt parameter start for GetTimeSteps().
This commit is contained in:
Gerhard Hoffmann 2024-01-22 13:28:38 +01:00
parent 506a665592
commit 15700a363d

View File

@ -13,36 +13,8 @@
using namespace std;
class Calculator {
QDateTime m_start;
mutable uint16_t m_timeStepCompensation = 0;
public:
explicit Calculator() = default;
explicit Calculator(QDateTime const start) : m_start(start) {
m_start.setTime(QTime(start.time().hour(), start.time().minute(), 0));
qCritical() << "init m_start time:" << m_start.toString(Qt::ISODate);
}
void setStartDateTime(QDateTime const &start) {
m_start = start;
m_start.setTime(QTime(start.time().hour(), start.time().minute(), 0));
qCritical() << "set m_start time:" << m_start.toString(Qt::ISODate);
}
QDateTime const &getStartDateTime() const {
return m_start;
}
QDateTime &getStartDateTime() {
return m_start;
}
void setTimeStepCompensation(uint16_t timeStepCompensation) {
m_timeStepCompensation = timeStepCompensation;
}
uint16_t getTimeStepCompensation() const {
return m_timeStepCompensation;
}
/// <summary>
/// Gets duration in seconds from cost
@ -72,7 +44,7 @@ public:
// helper function to find time steps for a tariff with PaymentMethod::Steps
// (e.g. Schoenau/Koenigsee)
//
QList<int> GetTimeSteps(Configuration *cfg) const;
QList<int> GetTimeSteps(Configuration *cfg, quint64 startInMinutes = QDateTime::currentSecsSinceEpoch() / 60) const;
QList<int> GetSteps(Configuration *cfg) const { return GetTimeSteps(cfg); }
// additional helper functions
@ -89,7 +61,7 @@ public:
}
// testing public:
private:
//private:
// Introduced for PaymentMethod::Steps (e.g. Schoenau)
// For tariff of following structure: only steps, no special days, nonstop.
uint32_t GetCostFromDuration(Configuration *cfg, QDateTime const &start, quint64 durationMinutes) const;