aboutsummaryrefslogtreecommitdiff
path: root/shared/src/iosMain
diff options
context:
space:
mode:
Diffstat (limited to 'shared/src/iosMain')
-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