diff options
author | Oliver Schwaneberg <oliver.schwaneberg@gmail.com> | 2018-02-04 20:07:32 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2018-02-04 13:40:02 -0800 |
commit | eb38a641490752578e3dddc7b7959cfd52e0be74 (patch) | |
tree | bdf4a1a6219721dfbabaffd89903ba6d02a86d1d /core/qthelper.cpp | |
parent | a32f12592baa72d2da5e527e7c296f6e11006ed7 (diff) | |
download | subsurface-eb38a641490752578e3dddc7b7959cfd52e0be74.tar.gz |
Do not remove seconds from duration input field
This change deals with issue #554.
If you enter a dive duration manually, the cell renderer cuts the seconds
away when the changes are saved. I added the helper "render_seconds_to_string"
as a counterpart to "parseDurationToSeconds". The helper keeps the seconds,
if not null. The rendering of the cell is done at two places in the code,
so I think it is cleaner to add a dedicated method for it.
Signed-off-by: Oliver Schwaneberg <oliver.schwaneberg@gmail.com>
Diffstat (limited to 'core/qthelper.cpp')
-rw-r--r-- | core/qthelper.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
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; |