diff options
-rw-r--r-- | helpers.h | 2 | ||||
-rw-r--r-- | qt-gui.cpp | 10 | ||||
-rw-r--r-- | qt-ui/maintab.cpp | 2 |
3 files changed, 9 insertions, 5 deletions
@@ -27,7 +27,7 @@ void set_default_dive_computer(const char *vendor, const char *product); void set_default_dive_computer_device(const char *name); QString getSubsurfaceDataPath(QString folderToFind); extern const QString get_dc_nickname(const char *model, uint32_t deviceid); -int gettimezoneoffset(); +int gettimezoneoffset(time_t when = 0); int parseTemperatureToMkelvin(const QString &text); QString get_dive_date_string(timestamp_t when); QString get_short_dive_date_string(timestamp_t when); diff --git a/qt-gui.cpp b/qt-gui.cpp index 68f65e76a..0f5342921 100644 --- a/qt-gui.cpp +++ b/qt-gui.cpp @@ -372,10 +372,14 @@ QString getSubsurfaceDataPath(QString folderToFind) return QString(""); } -int gettimezoneoffset() +int gettimezoneoffset(time_t when) { - QDateTime dt1 = QDateTime::currentDateTime(); - QDateTime dt2 = dt1.toUTC(); + QDateTime dt1, dt2; + if (when == 0) + dt1 = QDateTime::currentDateTime(); + else + dt1 = QDateTime::fromMSecsSinceEpoch(when * 1000); + dt2 = dt1.toUTC(); dt1.setTimeSpec(Qt::UTC); return dt2.secsTo(dt1); } diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index 4c46d36ac..7c85825d4 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -380,7 +380,7 @@ void MainTab::updateDiveInfo(bool clear) if (!clear) { updateGpsCoordinates(&displayed_dive); - QDateTime localTime = QDateTime::fromTime_t(displayed_dive.when - gettimezoneoffset()); + QDateTime localTime = QDateTime::fromTime_t(displayed_dive.when - gettimezoneoffset(displayed_dive.when)); ui.dateEdit->setDate(localTime.date()); ui.timeEdit->setTime(localTime.time()); if (MainWindow::instance() && MainWindow::instance()->dive_list()->selectedTrips().count() == 1) { |