mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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:
parent
325c4459ad
commit
7713c7e607
6 changed files with 20 additions and 18 deletions
|
@ -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);
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include "core/metrics.h"
|
||||
#include "core/divelist.h"
|
||||
#include "core/helpers.h"
|
||||
#include "core/dive.h"
|
||||
#include <QIcon>
|
||||
|
||||
static int nitrox_sort_value(struct dive *dive)
|
||||
|
@ -325,12 +326,12 @@ QString DiveItem::displayDepthWithUnit() const
|
|||
int DiveItem::countPhotos(dive *dive) const
|
||||
{ // Determine whether dive has pictures, and whether they were taken during or before/after dive.
|
||||
const int bufperiod = 120; // A 2-min buffer period. Photos within 2 min of dive are assumed as
|
||||
int diveDuration = dive->duration.seconds; // taken during the dive, not before/after.
|
||||
int diveTotaltime = dive_endtime(dive) - dive->when; // taken during the dive, not before/after.
|
||||
int pic_offset, icon_index = 0;
|
||||
FOR_EACH_PICTURE (dive) { // Step through each of the pictures for this dive:
|
||||
if (!picture) break; // if there are no pictures for this dive, return 0
|
||||
pic_offset = picture->offset.seconds;
|
||||
if ((pic_offset < -bufperiod) | (pic_offset > diveDuration+bufperiod)) {
|
||||
if ((pic_offset < -bufperiod) | (pic_offset > diveTotaltime+bufperiod)) {
|
||||
icon_index |= 0x02; // If picture is before/after the dive
|
||||
} // then set the appropriate bit ...
|
||||
else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue