diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2016-04-28 16:31:37 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2016-04-29 09:07:41 -0700 |
commit | 56ed3f1c6119b9ac86f602455d54318623640056 (patch) | |
tree | 0c342158ea4c2d2443139361deba786fa1b01bab /desktop-widgets | |
parent | 84166a4ee77502bdb4a981bc5404a1a970c579cc (diff) | |
download | subsurface-56ed3f1c6119b9ac86f602455d54318623640056.tar.gz |
Fix Qt date interfaces for times before 1970
This seems to work around the crazy QDateTime::fromTime_t() problem in Qt.
It is *very* lightly tested. In fact, the only test is that "test0.xml"
change that is part of this patch.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'desktop-widgets')
-rw-r--r-- | desktop-widgets/maintab.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/desktop-widgets/maintab.cpp b/desktop-widgets/maintab.cpp index a3cc151ef..f6e5b7dc6 100644 --- a/desktop-widgets/maintab.cpp +++ b/desktop-widgets/maintab.cpp @@ -493,7 +493,7 @@ void MainTab::updateDiveInfo(bool clear) // Subsurface always uses "local time" as in "whatever was the local time at the location" // so all time stamps have no time zone information and are in UTC - QDateTime localTime = QDateTime::fromTime_t(displayed_dive.when - gettimezoneoffset(displayed_dive.when)); + QDateTime localTime = QDateTime::fromMSecsSinceEpoch(1000*displayed_dive.when, Qt::UTC); localTime.setTimeSpec(Qt::UTC); ui.dateEdit->setDate(localTime.date()); ui.timeEdit->setTime(localTime.time()); @@ -1284,7 +1284,7 @@ void MainTab::on_dateEdit_dateChanged(const QDate &date) if (editMode == IGNORE || acceptingEdit == true) return; markChangedWidget(ui.dateEdit); - QDateTime dateTime = QDateTime::fromTime_t(displayed_dive.when - gettimezoneoffset(displayed_dive.when)); + QDateTime dateTime = QDateTime::fromMSecsSinceEpoch(1000*displayed_dive.when, Qt::UTC); dateTime.setTimeSpec(Qt::UTC); dateTime.setDate(date); DivePlannerPointsModel::instance()->getDiveplan().when = displayed_dive.when = dateTime.toTime_t(); @@ -1296,7 +1296,7 @@ void MainTab::on_timeEdit_timeChanged(const QTime &time) if (editMode == IGNORE || acceptingEdit == true) return; markChangedWidget(ui.timeEdit); - QDateTime dateTime = QDateTime::fromTime_t(displayed_dive.when - gettimezoneoffset(displayed_dive.when)); + QDateTime dateTime = QDateTime::fromMSecsSinceEpoch(1000*displayed_dive.when, Qt::UTC); dateTime.setTimeSpec(Qt::UTC); dateTime.setTime(time); DivePlannerPointsModel::instance()->getDiveplan().when = displayed_dive.when = dateTime.toTime_t(); |