summaryrefslogtreecommitdiffstats
path: root/desktop-widgets/tab-widgets
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2020-05-22 18:02:15 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-05-22 12:31:06 -0700
commitf63485b444bd8469d24c70f64f3097bed239c7a8 (patch)
tree4960697b8efbe14846c1180160e224d1d903d3b2 /desktop-widgets/tab-widgets
parent2ba2ea934aac45c6d8b3c6db920776fb2b29cc66 (diff)
downloadsubsurface-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 'desktop-widgets/tab-widgets')
-rw-r--r--desktop-widgets/tab-widgets/maintab.cpp14
1 files changed, 2 insertions, 12 deletions
diff --git a/desktop-widgets/tab-widgets/maintab.cpp b/desktop-widgets/tab-widgets/maintab.cpp
index d11581516..81c56a486 100644
--- a/desktop-widgets/tab-widgets/maintab.cpp
+++ b/desktop-widgets/tab-widgets/maintab.cpp
@@ -307,14 +307,6 @@ void MainTab::updateNotes(const struct dive *d)
}
}
-static QDateTime timestampToDateTime(timestamp_t when)
-{
- // 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::fromMSecsSinceEpoch(1000 * when, Qt::UTC);
- localTime.setTimeSpec(Qt::UTC);
- return localTime;
-}
void MainTab::updateDateTime(const struct dive *d)
{
QDateTime localTime = timestampToDateTime(d->when);
@@ -617,8 +609,7 @@ void MainTab::on_dateEdit_editingFinished()
{
if (ignoreInput || !current_dive)
return;
- QDateTime dateTime = QDateTime::fromMSecsSinceEpoch(1000*current_dive->when, Qt::UTC);
- dateTime.setTimeSpec(Qt::UTC);
+ QDateTime dateTime = timestampToDateTime(current_dive->when);
dateTime.setDate(ui.dateEdit->date());
shiftTime(dateTime);
}
@@ -627,8 +618,7 @@ void MainTab::on_timeEdit_editingFinished()
{
if (ignoreInput || !current_dive)
return;
- QDateTime dateTime = QDateTime::fromMSecsSinceEpoch(1000*current_dive->when, Qt::UTC);
- dateTime.setTimeSpec(Qt::UTC);
+ QDateTime dateTime = timestampToDateTime(current_dive->when);
dateTime.setTime(ui.timeEdit->time());
shiftTime(dateTime);
}