diff options
Diffstat (limited to 'shared/src')
-rw-r--r-- | shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/utils/ReportDates.kt | 11 | ||||
-rw-r--r-- | shared/src/iosMain/kotlin/mx/trackermap/TrackerMap/utils/DateUtils.kt | 22 |
2 files changed, 33 insertions, 0 deletions
diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/utils/ReportDates.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/utils/ReportDates.kt index 6c86d27..5298df3 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/utils/ReportDates.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/utils/ReportDates.kt @@ -22,6 +22,17 @@ import kotlinx.datetime.* @DelicateCoroutinesApi class ReportDates { + enum class PeriodTypes { + TODAY, + LAST_24, + YESTERDAY, + THIS_WEEK, + LAST_7, + THIS_MONTH, + LAST_30, + CUSTOM + } + sealed class ReportPeriod { val timezone = TimeZone.currentSystemDefault() val clock = Clock.System 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 |