cleanup: move formatting of gas type to string-format.cpp

Since the only caller was C++ code, this can be done in
C++ code, which removes memory-management headaches.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2023-03-17 08:21:47 +01:00 committed by Dirk Hohndel
parent 468c1d8d61
commit 264adacba1
5 changed files with 26 additions and 37 deletions

View file

@ -1,6 +1,7 @@
#include "string-format.h"
#include "dive.h"
#include "divesite.h"
#include "format.h"
#include "qthelper.h"
#include "subsurface-string.h"
#include "trip.h"
@ -261,6 +262,29 @@ QString formatDiveDateTime(const dive *d)
localTime.time().toString(prefs.time_format));
}
QString formatDiveGasString(const dive *d)
{
int o2, he, o2max;
get_dive_gas(d, &o2, &he, &o2max);
o2 = (o2 + 5) / 10;
he = (he + 5) / 10;
o2max = (o2max + 5) / 10;
if (he) {
if (o2 == o2max)
return qasprintf_loc("%d/%d", o2, he);
else
return qasprintf_loc("%d/%d…%d%%", o2, he, o2max);
} else if (o2) {
if (o2 == o2max)
return qasprintf_loc("%d%%", o2);
else
return qasprintf_loc("%d…%d%%", o2, o2max);
} else {
return gettextFromC::tr("air");
}
}
QString formatDayOfWeek(int day)
{
// I can't wrap my head around the fact that Sunday is the