aboutsummaryrefslogtreecommitdiff
path: root/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/utils/Formatter.kt
diff options
context:
space:
mode:
authorIván Ávalos <avalos@disroot.org>2022-01-04 22:37:36 -0600
committerIván Ávalos <avalos@disroot.org>2022-01-04 22:37:36 -0600
commit3e15173c529b2b307e813288f4728f5110fb5a78 (patch)
treee0bb58b98b6667a01190ed25b4b24d29a1c71568 /shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/utils/Formatter.kt
parent793ccb0b907ac4b1364efd3e9a8df558c0346249 (diff)
downloadetbsa-trackermap-mobile-3e15173c529b2b307e813288f4728f5110fb5a78.tar.gz
etbsa-trackermap-mobile-3e15173c529b2b307e813288f4728f5110fb5a78.tar.bz2
etbsa-trackermap-mobile-3e15173c529b2b307e813288f4728f5110fb5a78.zip
Implemented formatSpeed, redesigned UnitInformationFragment, added button to open device location in map, minor UI tweaks and added translations.
Diffstat (limited to 'shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/utils/Formatter.kt')
-rw-r--r--shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/utils/Formatter.kt15
1 files changed, 15 insertions, 0 deletions
diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/utils/Formatter.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/utils/Formatter.kt
index 133c028..af4e14d 100644
--- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/utils/Formatter.kt
+++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/utils/Formatter.kt
@@ -1,6 +1,7 @@
package mx.trackermap.TrackerMap.utils
import kotlinx.datetime.*
+import kotlin.math.round
class Formatter {
companion object {
@@ -8,5 +9,19 @@ class Formatter {
return date.substring(0 until date.indexOf('+'))
.toLocalDateTime().toString().replace('T', ' ')
}
+
+ fun formatSpeed(speed: Double, unit: SpeedUnit): String {
+ return when (unit) {
+ SpeedUnit.KMH -> {
+ "${(speed * 1.852).toInt()} km/h"
+ }
+ SpeedUnit.MPH -> {
+ "${(speed * 1.15078).toInt()} mph"
+ }
+ SpeedUnit.KN -> {
+ "${speed.toInt()} kn"
+ }
+ }
+ }
}
} \ No newline at end of file