mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-19 14:25:27 +00:00
Correctly format depth and time
We really need those leading 0s. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
e156b00f05
commit
ce235bd581
1 changed files with 10 additions and 14 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue