diff options
author | Iván Ávalos <avalos@disroot.org> | 2021-12-30 19:13:13 -0600 |
---|---|---|
committer | Iván Ávalos <avalos@disroot.org> | 2021-12-30 19:13:13 -0600 |
commit | 4be0f818e17320145ea7508d89bb21d0e0e7c0bf (patch) | |
tree | c23153778b780a1b781a07ff378d32ce15e804fd | |
parent | 964820d1e4416fd1d36e100f39ecc15bab480e90 (diff) | |
download | etbsa-trackermap-mobile-4be0f818e17320145ea7508d89bb21d0e0e7c0bf.tar.gz etbsa-trackermap-mobile-4be0f818e17320145ea7508d89bb21d0e0e7c0bf.tar.bz2 etbsa-trackermap-mobile-4be0f818e17320145ea7508d89bb21d0e0e7c0bf.zip |
Implemented datetime formatting
3 files changed, 19 insertions, 9 deletions
diff --git a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/devices/DevicesAdapter.kt b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/devices/DevicesAdapter.kt index ffe6ca7..33dd5b9 100644 --- a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/devices/DevicesAdapter.kt +++ b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/devices/DevicesAdapter.kt @@ -1,17 +1,13 @@ package mx.trackermap.TrackerMap.android.devices import android.graphics.Color -import android.graphics.ColorFilter -import android.util.Log import android.view.LayoutInflater import android.view.View import android.view.ViewGroup -import android.view.ViewStructure -import androidx.core.content.res.ResourcesCompat import androidx.recyclerview.widget.RecyclerView -import kotlinx.serialization.json.JsonNull import mx.trackermap.TrackerMap.android.R import mx.trackermap.TrackerMap.android.databinding.UnitItemBinding +import mx.trackermap.TrackerMap.utils.Formatter import mx.trackermap.TrackerMap.client.models.UnitInformation enum class Action { @@ -73,7 +69,9 @@ class DevicesAdapter( driverName.text = unit.device.contact unitSpeed.text = context.getString(R.string.unit_speed_format, unit.position?.speed?.toInt() ?: 0) lastAddress.text = unit.position?.address - lastDate.text = "yyyy/mm/dd, hh:mm" + unit.position?.fixTime?.let { + lastDate.text = Formatter.formatDate(it) + } actionCallback?.let { callback -> unitCard.setOnClickListener { callback(unit, Action.CLICK) } detailsButton.setOnClickListener { callback(unit, Action.DETAILS) } diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/Position.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/Position.kt index 9a16615..5286b46 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/Position.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/Position.kt @@ -46,11 +46,11 @@ data class Position ( val deviceId: Int? = null, val protocol: String? = null, /* in IS0 8601 format. eg. `1963-11-22T18:30:00Z` */ -// val deviceTime: LocalDateTime? = null, + val deviceTime: String? = null, /* in IS0 8601 format. eg. `1963-11-22T18:30:00Z` */ -// val fixTime: LocalDateTime? = null, + val fixTime: String? = null, /* in IS0 8601 format. eg. `1963-11-22T18:30:00Z` */ -// val serverTime: LocalDateTime? = null, + val serverTime: String? = null, val outdated: Boolean? = null, val valid: Boolean? = null, val latitude: Double? = null, diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/utils/Formatter.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/utils/Formatter.kt new file mode 100644 index 0000000..133c028 --- /dev/null +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/utils/Formatter.kt @@ -0,0 +1,12 @@ +package mx.trackermap.TrackerMap.utils + +import kotlinx.datetime.* + +class Formatter { + companion object { + fun formatDate(date: String): String { + return date.substring(0 until date.indexOf('+')) + .toLocalDateTime().toString().replace('T', ' ') + } + } +}
\ No newline at end of file |