diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2013-04-24 16:03:14 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-04-24 16:03:14 -0700 |
commit | ce235bd58133fd0ebde4d7156dd5cb4c62abeb60 (patch) | |
tree | 185ca2da50bb990b758b66404dba6aa13c1493de | |
parent | e156b00f05c99b990a5e482c23e172e168d80b74 (diff) | |
download | subsurface-ce235bd58133fd0ebde4d7156dd5cb4c62abeb60.tar.gz |
Correctly format depth and time
We really need those leading 0s.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r-- | qt-ui/models.cpp | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/qt-ui/models.cpp b/qt-ui/models.cpp index 31610facd..e7f4b1f8b 100644 --- a/qt-ui/models.cpp +++ b/qt-ui/models.cpp @@ -338,7 +338,7 @@ QString DiveItem::displayDepth() const QString fract, str; if (get_units()->length == units::METERS) { fract = QString::number((unsigned)(mm % scale) / 10); - str = QString("%1.%2").arg((unsigned)(mm / scale)).arg(fract); + str = QString("%1.%2").arg((unsigned)(mm / scale)).arg(fract, 2, QChar('0')); } if (get_units()->length == units::FEET) { str = QString::number(mm_to_feet(mm),'f',2); @@ -348,23 +348,19 @@ QString DiveItem::displayDepth() const QString DiveItem::displayDuration() const { - int hrs, mins, secs, val; - const int minutes_hour = 60; - const int seconds_minute= 60; + int hrs, mins, secs; - val = seconds; - secs = seconds % seconds_minute; - val /= seconds_minute; - mins = val % seconds_minute; - val /= minutes_hour; - hrs = val % minutes_hour; + secs = seconds % 60; + mins = seconds / 60; + hrs = mins / 60; + mins -= hrs * 60; QString displayTime; - if (hrs > 0) - displayTime = QString("%1:%2:%3").arg(hrs).arg(mins).arg(secs); + if (hrs) + displayTime = QString("%1:%2:").arg(hrs).arg(mins, 2, 10, QChar('0')); else - displayTime = QString("%1:%2").arg(mins).arg(secs); - + displayTime = QString("%1:").arg(mins); + displayTime += QString("%1").arg(secs, 2, 10, QChar('0')); return displayTime; } |