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

@ -6,6 +6,7 @@
#include <core/helpers.h>
#include <core/statistics.h>
#include <core/display.h>
#include <core/dive.h>
TabDiveInformation::TabDiveInformation(QWidget *parent) : TabBase(parent), ui(new Ui::TabDiveInformation())
{
@ -81,7 +82,7 @@ void TabDiveInformation::updateData()
process_all_dives(&displayed_dive, &prevd);
if (prevd)
ui->surfaceIntervalText->setText(get_dive_surfint_string(displayed_dive.when - (prevd->when + prevd->duration.seconds), tr("d"), tr("h"), tr("min")));
ui->surfaceIntervalText->setText(get_dive_surfint_string(displayed_dive.when - (dive_endtime(prevd)), tr("d"), tr("h"), tr("min")));
else
ui->surfaceIntervalText->clear();