diff options
-rw-r--r-- | core/helpers.h | 1 | ||||
-rw-r--r-- | core/qthelper.cpp | 8 | ||||
-rw-r--r-- | desktop-widgets/tab-widgets/maintab.cpp | 4 |
3 files changed, 11 insertions, 2 deletions
diff --git a/core/helpers.h b/core/helpers.h index 06c1c8527..57be623c5 100644 --- a/core/helpers.h +++ b/core/helpers.h @@ -36,6 +36,7 @@ int parseWeightToGrams(const QString &text); int parsePressureToMbar(const QString &text); int parseGasMixO2(const QString &text); int parseGasMixHE(const QString &text); +QString render_seconds_to_string(int seconds); QString get_dive_duration_string(timestamp_t when, QString hoursText, QString minutesText, QString secondsText = QObject::tr("sec"), QString separator = ":", bool isFreeDive = false); QString get_dive_surfint_string(timestamp_t when, QString daysText, QString hoursText, QString minutesText, QString separator = " ", int maxdays = 4); QString get_dive_date_string(timestamp_t when); diff --git a/core/qthelper.cpp b/core/qthelper.cpp index 262399a5f..03dd56637 100644 --- a/core/qthelper.cpp +++ b/core/qthelper.cpp @@ -743,6 +743,14 @@ int gettimezoneoffset(timestamp_t when) return dt2.secsTo(dt1); } +QString render_seconds_to_string(int seconds) +{ + if (seconds % 60 == 0) + return QDateTime::fromTime_t(seconds).toUTC().toString("h:mm"); + else + return QDateTime::fromTime_t(seconds).toUTC().toString("h:mm:ss"); +} + int parseDurationToSeconds(const QString &text) { int secs; diff --git a/desktop-widgets/tab-widgets/maintab.cpp b/desktop-widgets/tab-widgets/maintab.cpp index 2f5dd990e..2e21a1655 100644 --- a/desktop-widgets/tab-widgets/maintab.cpp +++ b/desktop-widgets/tab-widgets/maintab.cpp @@ -393,7 +393,7 @@ void MainTab::updateDepthDuration() ui.depthLabel->setVisible(true); ui.duration->setVisible(true); ui.durationLabel->setVisible(true); - ui.duration->setText(QDateTime::fromTime_t(displayed_dive.duration.seconds).toUTC().toString("h:mm")); + ui.duration->setText(render_seconds_to_string(displayed_dive.duration.seconds)); ui.depth->setText(get_depth_string(displayed_dive.maxdepth, true)); } @@ -579,7 +579,7 @@ void MainTab::updateDiveInfo(bool clear) ui.durationLabel->setVisible(isManual); } } - ui.duration->setText(QDateTime::fromTime_t(displayed_dive.duration.seconds).toUTC().toString("h:mm")); + ui.duration->setText(render_seconds_to_string(displayed_dive.duration.seconds)); ui.depth->setText(get_depth_string(displayed_dive.maxdepth, true)); ui.DiveType->setCurrentIndex(get_dive_dc(&displayed_dive, dc_number)->divemode); |