mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
84166a4ee7
commit
56ed3f1c61
4 changed files with 13 additions and 14 deletions
|
@ -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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue