aboutsummaryrefslogtreecommitdiff
path: root/shared/src/iosMain/kotlin
diff options
context:
space:
mode:
authorIván Ávalos <avalos@disroot.org>2022-04-12 00:24:14 -0500
committerIván Ávalos <avalos@disroot.org>2022-04-12 00:24:14 -0500
commit10cb1152a2cb76609e6f65a0e7a2690013d3de16 (patch)
treee12dd86d31fbc4e9dfa672a093efce52ec9dc836 /shared/src/iosMain/kotlin
parent546738888395565ac2d5fe2cfb941ecdd0c1df45 (diff)
downloadetbsa-trackermap-mobile-10cb1152a2cb76609e6f65a0e7a2690013d3de16.tar.gz
etbsa-trackermap-mobile-10cb1152a2cb76609e6f65a0e7a2690013d3de16.tar.bz2
etbsa-trackermap-mobile-10cb1152a2cb76609e6f65a0e7a2690013d3de16.zip
Initial version of custom reports in iOS
Diffstat (limited to 'shared/src/iosMain/kotlin')
-rw-r--r--shared/src/iosMain/kotlin/mx/trackermap/TrackerMap/utils/DateUtils.kt22
1 files changed, 22 insertions, 0 deletions
diff --git a/shared/src/iosMain/kotlin/mx/trackermap/TrackerMap/utils/DateUtils.kt b/shared/src/iosMain/kotlin/mx/trackermap/TrackerMap/utils/DateUtils.kt
new file mode 100644
index 0000000..7286ea5
--- /dev/null
+++ b/shared/src/iosMain/kotlin/mx/trackermap/TrackerMap/utils/DateUtils.kt
@@ -0,0 +1,22 @@
+package mx.trackermap.TrackerMap.utils
+
+import kotlinx.datetime.*
+import platform.Foundation.NSDate
+import platform.Foundation.NSDateFormatter
+
+actual class DateUtils {
+ actual companion object {
+ fun iosDateToKotlin(date: NSDate): LocalDateTime {
+ val timezone = TimeZone.currentSystemDefault()
+ return date.toKotlinInstant().toLocalDateTime(timezone)
+ }
+
+ actual fun formatDate(date: LocalDateTime): String {
+ val timezone = TimeZone.currentSystemDefault()
+ val iosDate = date.toInstant(timezone).toNSDate()
+ val formatter = NSDateFormatter()
+ formatter.setDateFormat("yyyy-MM-dd HH:mm")
+ return formatter.stringFromDate(iosDate)
+ }
+ }
+} \ No newline at end of file