Use helper function dive_endtime() where apropriate

Calculating dive.when + dive.duration doesn't always give the correct
endtime of a dive especially when a dive has surface interval(s) in
the middle.
Using the helper function dive_endtime() fixes this issue.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
This commit is contained in:
Stefan Fuchs 2017-09-30 18:00:34 +02:00 committed by Lubomir I. Ivanov
parent 325c4459ad
commit 7713c7e607
6 changed files with 20 additions and 18 deletions

View file

@ -58,7 +58,7 @@ void DivePlannerPointsModel::setupStartTime()
startTime = QDateTime::currentDateTimeUtc().addSecs(3600 + gettimezoneoffset());
if (dive_table.nr) {
struct dive *d = get_dive(dive_table.nr - 1);
time_t ends = d->when + d->duration.seconds;
time_t ends = dive_endtime(d);
time_t diff = ends - startTime.toTime_t();
if (diff > 0) {
startTime = startTime.addSecs(diff + 3600);