blob: 7286ea5c983c0debe5ac349e7bed675dacda88ed (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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)
}
}
}
|