From c11d9d0aaa0428e93df978642a54ba466ccf4e93 Mon Sep 17 00:00:00 2001 From: Iván Ávalos Date: Thu, 30 Dec 2021 19:13:13 -0600 Subject: Implemented datetime formatting --- .../mx/trackermap/TrackerMap/client/models/Position.kt | 6 +++--- .../kotlin/mx/trackermap/TrackerMap/utils/Formatter.kt | 12 ++++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/utils/Formatter.kt (limited to 'shared/src') 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 -- cgit v1.2.3