Add additional constructor.

This commit is contained in:
Gerhard Hoffmann 2024-09-17 16:53:45 +02:00
parent 932d4e8cb9
commit 8c7afdfcb1
2 changed files with 17 additions and 4 deletions

View File

@ -10,6 +10,7 @@ class ATBTime {
public:
explicit ATBTime();
explicit ATBTime(int h, int m, int s = 0, int ms = 0);
explicit ATBTime(QString const &time);
int hour() const { return m_time.time().hour(); }
int minute() const { return m_time.time().minute(); }

View File

@ -2,18 +2,30 @@
ATBTime::ATBTime()
: m_end(QDateTime::fromString("1970-01-02T00:00:00"))
, m_time(QDateTime::fromString("1970-01-01T00:00:00")) {
: m_end(QDateTime::fromString("1970-01-02T00:00:00", Qt::ISODate))
, m_time(QDateTime::fromString("1970-01-01T00:00:00", Qt::ISODate)) {
}
ATBTime::ATBTime(int h, int m, int s, int ms)
: m_end(QDateTime::fromString("1970-01-02T00:00:00"))
, m_time(QDateTime::fromString("1970-01-01T00:00:00")) {
: m_end(QDateTime::fromString("1970-01-02T00:00:00", Qt::ISODate))
, m_time(QDateTime::fromString("1970-01-01T00:00:00", Qt::ISODate)) {
QTime t(h, m, s, ms);
m_time.setTime(t);
}
ATBTime::ATBTime(QString const &t)
: m_end(QDateTime::fromString("1970-01-02T00:00:00"))
, m_time(QDateTime::fromString("1970-01-01T00:00:00")) {
if (t == "24:00:00") {
m_time = m_end;
} else {
m_time.setTime(QTime::fromString(t, Qt::ISODate));
}
}
QTime ATBTime::addMSecs(int ms) const {
return m_time.time().addMSecs(ms);
}