From: robertlipe Date: Fri, 19 Jul 2013 17:01:07 +0000 (+0000) Subject: Provide msecsTo in DateTime for Qt 4.6. X-Git-Tag: archive/raspbian/1.10.0+ds-2+rpi1~1^2~12^2~11^2~499 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=b7bde1f07bab625d283bcfffb0b1142fd30064c6;p=gpsbabel.git Provide msecsTo in DateTime for Qt 4.6. --- diff --git a/gpsbabel/src/core/datetime.h b/gpsbabel/src/core/datetime.h index 4cab68428..cebb55b94 100644 --- a/gpsbabel/src/core/datetime.h +++ b/gpsbabel/src/core/datetime.h @@ -104,6 +104,14 @@ public: QTime time(this->time()); return time.hour() * 10000 + time.minute() * 100 + time.second(); } + // Qt 4.6 and under doesn't have msecsTo. Fortunately, it's easy to + // provide. It's a 64-bit because if the times aren't on the same day, + // the returned value can be quite large. + int64_t msecsTo(const QDateTime& dt) { + qint64 days = this->daysTo(dt); + qint64 msecs = this->time().msecsTo(dt.time()); + return days * (1000 * 3600 * 24) + msecs; + } // Like toString, but with subsecond time that's included only when // the trailing digits aren't .000. Always UTC. @@ -116,6 +124,7 @@ public: } return this->toUTC().toString(format); } + private: time_t t_;