From c62baea03259aeb9b08aeb53be9a0fcac9a589ed Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Thu, 7 Jan 2016 21:55:04 -0800 Subject: Correctly adjust time stamp of GPS fixes Signed-off-by: Dirk Hohndel --- subsurface-core/gpslocation.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'subsurface-core') diff --git a/subsurface-core/gpslocation.cpp b/subsurface-core/gpslocation.cpp index cbcb6910b..40fb0e54e 100644 --- a/subsurface-core/gpslocation.cpp +++ b/subsurface-core/gpslocation.cpp @@ -119,7 +119,7 @@ QString GpsLocation::currentPosition() void GpsLocation::newPosition(QGeoPositionInfo pos) { - time_t lastTime; + int64_t lastTime; QGeoCoordinate lastCoord; QString msg("received new position %1"); status(qPrintable(msg.arg(pos.coordinate().toString()))); @@ -133,11 +133,14 @@ void GpsLocation::newPosition(QGeoPositionInfo pos) // if we have no record stored or if at least the configured minimum // time has passed or we moved at least the configured minimum distance if (!nr || waitingForPosition || - (time_t)pos.timestamp().toTime_t() > lastTime + prefs.time_threshold || + (int64_t)pos.timestamp().toTime_t() > lastTime + prefs.time_threshold || lastCoord.distanceTo(pos.coordinate()) > prefs.distance_threshold) { waitingForPosition = false; geoSettings->setValue("count", nr + 1); - geoSettings->setValue(QString("gpsFix%1_time").arg(nr), pos.timestamp().toTime_t()); + + int64_t when = pos.timestamp().toTime_t(); + when += gettimezoneoffset(when); + geoSettings->setValue(QString("gpsFix%1_time").arg(nr), when); geoSettings->setValue(QString("gpsFix%1_lat").arg(nr), rint(pos.coordinate().latitude() * 1000000)); geoSettings->setValue(QString("gpsFix%1_lon").arg(nr), rint(pos.coordinate().longitude() * 1000000)); geoSettings->sync(); -- cgit v1.2.3-70-g09d2