aboutsummaryrefslogtreecommitdiff
path: root/shared
diff options
context:
space:
mode:
authorIván Ávalos <avalos@disroot.org>2023-09-26 19:32:13 -0600
committerIván Ávalos <avalos@disroot.org>2023-09-26 19:32:13 -0600
commit3022b877d0cf9b7546c80953237c7bca5a4afa50 (patch)
tree7d38faea9ec6648d0fc60f4a0cb1c8fb881a82e7 /shared
parent6b6b521c157dfe03797b1dec64f8a615e73a8dfa (diff)
downloadetbsa-trackermap-mobile-3022b877d0cf9b7546c80953237c7bca5a4afa50.tar.gz
etbsa-trackermap-mobile-3022b877d0cf9b7546c80953237c7bca5a4afa50.tar.bz2
etbsa-trackermap-mobile-3022b877d0cf9b7546c80953237c7bca5a4afa50.zip
[shared] Fix hourmeter for some devices
Diffstat (limited to 'shared')
-rw-r--r--shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/UnitInformation.kt12
1 files changed, 11 insertions, 1 deletions
diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/UnitInformation.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/UnitInformation.kt
index 6afa350..33e85ee 100644
--- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/UnitInformation.kt
+++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/UnitInformation.kt
@@ -53,5 +53,15 @@ data class UnitInformation(
} ?: EngineStop.UNKNOWN
} else EngineStop.UNKNOWN
- fun getHourmeter() = position?.attributes?.get("hours")?.longOrNull
+ fun getHourmeter() = position?.attributes?.let { attrs ->
+ if ("io16" in attrs) {
+ // Minutes
+ attrs["io16"]?.longOrNull?.let { it * 60 * 1000 }
+ } else if ("hours" in attrs) {
+ // Milliseconds
+ attrs["hours"]?.longOrNull
+ } else {
+ null
+ }
+ }
} \ No newline at end of file