From 8f80129bac29227a03c35940af9d197ef0fa6398 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Fri, 22 May 2020 18:53:25 +0200 Subject: cleanup: create common QDateTime -> timestamp conversion function In analogy to the timestamp -> QDateTime conversion, create a common function. 1) For symmetry with the opposite conversion. 2) To remove numerous inconsistencies. 3) To remove use of the deprecated QDateTime::toTime_t() function. Signed-off-by: Berthold Stoeger --- qt-models/diveplannermodel.cpp | 6 +++--- qt-models/divesummarymodel.cpp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'qt-models') diff --git a/qt-models/diveplannermodel.cpp b/qt-models/diveplannermodel.cpp index d0b919a61..ebcbeb51e 100644 --- a/qt-models/diveplannermodel.cpp +++ b/qt-models/diveplannermodel.cpp @@ -85,7 +85,7 @@ void DivePlannerPointsModel::setupStartTime() if (dive_table.nr) { struct dive *d = get_dive(dive_table.nr - 1); time_t ends = dive_endtime(d); - time_t diff = ends - startTime.toTime_t(); + time_t diff = ends - dateTimeToTimestamp(startTime); if (diff > 0) { startTime = startTime.addSecs(diff + 3600); } @@ -700,7 +700,7 @@ void DivePlannerPointsModel::setSurfaceSegment(int duration) void DivePlannerPointsModel::setStartDate(const QDate &date) { startTime.setDate(date); - diveplan.when = startTime.toTime_t(); + diveplan.when = dateTimeToTimestamp(startTime); displayed_dive.when = diveplan.when; emitDataChanged(); } @@ -708,7 +708,7 @@ void DivePlannerPointsModel::setStartDate(const QDate &date) void DivePlannerPointsModel::setStartTime(const QTime &t) { startTime.setTime(t); - diveplan.when = startTime.toTime_t(); + diveplan.when = dateTimeToTimestamp(startTime); displayed_dive.when = diveplan.when; emitDataChanged(); } diff --git a/qt-models/divesummarymodel.cpp b/qt-models/divesummarymodel.cpp index f12a345e5..d187f2b58 100644 --- a/qt-models/divesummarymodel.cpp +++ b/qt-models/divesummarymodel.cpp @@ -263,7 +263,7 @@ void DiveSummaryModel::calc(int column, int period) if (startTime == currentTime) start = 0; else - start = startTime.toMSecsSinceEpoch() / 1000L + gettimezoneoffset(); + start = dateTimeToTimestamp(startTime) + gettimezoneoffset(); // Loop over all dives and sum up data Stats stats = loopDives(start); -- cgit v1.2.3-70-g09d2