diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2020-05-22 18:02:15 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2020-05-22 12:31:06 -0700 |
commit | f63485b444bd8469d24c70f64f3097bed239c7a8 (patch) | |
tree | 4960697b8efbe14846c1180160e224d1d903d3b2 /core/gpslocation.cpp | |
parent | 2ba2ea934aac45c6d8b3c6db920776fb2b29cc66 (diff) | |
download | subsurface-f63485b444bd8469d24c70f64f3097bed239c7a8.tar.gz |
cleanup: move timestampToDateTime() to qthelper.cpp
Move this function from maintab.cpp to qthelper.cpp. Since the
functionality was used in numerous places, use the helper function
there as well. This removes a number of inconsistencies. For example,
sometime setTimeSpec(Qt::UTC) was called, even though the
QDateTime object was already created with that time spec.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core/gpslocation.cpp')
-rw-r--r-- | core/gpslocation.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/core/gpslocation.cpp b/core/gpslocation.cpp index feea645e1..ebd5b1950 100644 --- a/core/gpslocation.cpp +++ b/core/gpslocation.cpp @@ -133,7 +133,7 @@ QString GpsLocation::currentPosition() if (!hasLocationsSource()) return tr("Unknown GPS location (no GPS source)"); if (m_trackers.count()) { - QDateTime lastFixTime = QDateTime().fromMSecsSinceEpoch((m_trackers.lastKey() - gettimezoneoffset(m_trackers.lastKey())) * 1000); + QDateTime lastFixTime = timestampToDateTime(m_trackers.lastKey() - gettimezoneoffset(m_trackers.lastKey())); QDateTime now = QDateTime::currentDateTime(); int delta = lastFixTime.secsTo(now); qDebug() << "lastFixTime" << lastFixTime.toString() << "now" << now.toString() << "delta" << delta; @@ -173,7 +173,7 @@ void GpsLocation::newPosition(QGeoPositionInfo pos) if (!nr || waitingForPosition || delta > prefs.time_threshold || lastCoord.distanceTo(pos.coordinate()) > prefs.distance_threshold) { QString msg = QStringLiteral("received new position %1 after delta %2 threshold %3 (now %4 last %5)"); - status(qPrintable(msg.arg(pos.coordinate().toString()).arg(delta).arg(prefs.time_threshold).arg(pos.timestamp().toString()).arg(QDateTime().fromMSecsSinceEpoch(lastTime * 1000).toString()))); + status(qPrintable(msg.arg(pos.coordinate().toString()).arg(delta).arg(prefs.time_threshold).arg(pos.timestamp().toString()).arg(timestampToDateTime(lastTime).toString()))); waitingForPosition = false; acquiredPosition(); gpsTracker gt; @@ -182,7 +182,7 @@ void GpsLocation::newPosition(QGeoPositionInfo pos) gt.location = create_location(pos.coordinate().latitude(), pos.coordinate().longitude()); addFixToStorage(gt); gpsTracker gtNew = m_trackers.last(); - qDebug() << "newest fix is now at" << QDateTime().fromMSecsSinceEpoch(gtNew.when - gettimezoneoffset(gtNew.when) * 1000).toString(); + qDebug() << "newest fix is now at" << timestampToDateTime(gtNew.when - gettimezoneoffset(gtNew.when)).toString(); } } |