mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Add helper to parse pressure strings.
Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
bc84d280b8
commit
9c5b97e6cf
2 changed files with 22 additions and 0 deletions
|
@ -35,6 +35,7 @@ int gettimezoneoffset(timestamp_t when = 0);
|
|||
int parseLengthToMm(const QString &text);
|
||||
int parseTemperatureToMkelvin(const QString &text);
|
||||
int parseWeightToGrams(const QString &text);
|
||||
int parsePressureToMbar(const QString &text);
|
||||
QString get_dive_duration_string(timestamp_t when, QString hourText, QString minutesText);
|
||||
QString get_dive_date_string(timestamp_t when);
|
||||
QString get_short_dive_date_string(timestamp_t when);
|
||||
|
|
|
@ -850,6 +850,27 @@ int parseWeightToGrams(const QString &text)
|
|||
return grams;
|
||||
}
|
||||
|
||||
int parsePressureToMbar(const QString &text)
|
||||
{
|
||||
int mbar;
|
||||
QString numOnly = text;
|
||||
numOnly.replace(",", ".").remove(QRegExp("[^0-9.]"));
|
||||
if (numOnly.isEmpty())
|
||||
return 0;
|
||||
double number = numOnly.toDouble();
|
||||
switch (prefs.units.pressure) {
|
||||
case units::BAR:
|
||||
mbar = rint(number * 1000);
|
||||
break;
|
||||
case units::PSI:
|
||||
mbar = psi_to_mbar(number);
|
||||
break;
|
||||
default:
|
||||
mbar = 0;
|
||||
}
|
||||
return mbar;
|
||||
}
|
||||
|
||||
QString get_dive_duration_string(timestamp_t when, QString hourText, QString minutesText)
|
||||
{
|
||||
int hrs, mins;
|
||||
|
|
Loading…
Add table
Reference in a new issue