mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
Merge pull request #503 from meshtastic/2.2.24_Working_Changes
Make temp have no decimal places
This commit is contained in:
commit
f38d0d55d7
2 changed files with 11 additions and 9 deletions
|
|
@ -11,7 +11,9 @@ extension Float {
|
|||
|
||||
func formattedTemperature() -> String {
|
||||
let temperature = Measurement<UnitTemperature>(value: Double(self), unit: .celsius)
|
||||
return temperature.formatted(.measurement(width: .narrow, usage: .weather))
|
||||
let mf = MeasurementFormatter()
|
||||
mf.numberFormatter.maximumFractionDigits = 0
|
||||
return mf.string(from: temperature)
|
||||
}
|
||||
func localeTemperature() -> Double {
|
||||
let temperature = Measurement<UnitTemperature>(value: Double(self), unit: .celsius)
|
||||
|
|
|
|||
|
|
@ -81,19 +81,19 @@ struct EnvironmentMetricsLog: View {
|
|||
Text(em.temperature.formattedTemperature())
|
||||
}
|
||||
TableColumn("Humidity") { em in
|
||||
Text("\(String(format: "%.2f", em.relativeHumidity))%")
|
||||
Text("\(String(format: "%.0f", em.relativeHumidity))%")
|
||||
}
|
||||
TableColumn("Barometric Pressure") { em in
|
||||
Text("\(String(format: "%.2f", em.barometricPressure)) hPa")
|
||||
Text("\(String(format: "%.1f", em.barometricPressure)) hPa")
|
||||
}
|
||||
TableColumn("gas.resistance") { em in
|
||||
Text("\(String(format: "%.2f", em.gasResistance)) ohms")
|
||||
Text("\(String(format: "%.1f", em.gasResistance)) ohms")
|
||||
}
|
||||
TableColumn("current") { em in
|
||||
Text("\(String(format: "%.2f", em.current))")
|
||||
Text("\(String(format: "%.1f", em.current))")
|
||||
}
|
||||
TableColumn("voltage") { em in
|
||||
Text("\(String(format: "%.2f", em.voltage))")
|
||||
Text("\(String(format: "%.1f", em.voltage))")
|
||||
}
|
||||
TableColumn("timestamp") { em in
|
||||
Text(em.time?.formattedDate(format: dateFormatString) ?? "unknown.age".localized)
|
||||
|
|
@ -134,11 +134,11 @@ struct EnvironmentMetricsLog: View {
|
|||
|
||||
Text(em.temperature.formattedTemperature())
|
||||
.font(.caption)
|
||||
Text("\(String(format: "%.2f", em.relativeHumidity))%")
|
||||
Text("\(String(format: "%.0f", em.relativeHumidity))%")
|
||||
.font(.caption)
|
||||
Text("\(String(format: "%.2f", em.barometricPressure))")
|
||||
Text("\(String(format: "%.1f", em.barometricPressure))")
|
||||
.font(.caption)
|
||||
Text("\(String(format: "%.2f", em.gasResistance))")
|
||||
Text("\(String(format: "%.1f", em.gasResistance))")
|
||||
.font(.caption)
|
||||
Text(em.time?.formattedDate(format: dateFormatString) ?? "unknown.age".localized)
|
||||
.font(.caption)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue