From f63485b444bd8469d24c70f64f3097bed239c7a8 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Fri, 22 May 2020 18:02:15 +0200 Subject: 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 --- core/subsurface-qt/diveobjecthelper.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'core/subsurface-qt') diff --git a/core/subsurface-qt/diveobjecthelper.cpp b/core/subsurface-qt/diveobjecthelper.cpp index 7c8651507..45cb73868 100644 --- a/core/subsurface-qt/diveobjecthelper.cpp +++ b/core/subsurface-qt/diveobjecthelper.cpp @@ -328,15 +328,13 @@ DiveObjectHelperGrantlee::DiveObjectHelperGrantlee(const struct dive *d) : QString DiveObjectHelper::date() const { - QDateTime localTime = QDateTime::fromMSecsSinceEpoch(1000 * timestamp, Qt::UTC); - localTime.setTimeSpec(Qt::UTC); + QDateTime localTime = timestampToDateTime(timestamp); return localTime.date().toString(prefs.date_format_short); } QString DiveObjectHelper::time() const { - QDateTime localTime = QDateTime::fromMSecsSinceEpoch(1000 * timestamp, Qt::UTC); - localTime.setTimeSpec(Qt::UTC); + QDateTime localTime = timestampToDateTime(timestamp); return localTime.time().toString(prefs.time_format); } -- cgit v1.2.3-70-g09d2