From 109050d0cf9ca0ecd871a38f21354b70310fcc61 Mon Sep 17 00:00:00 2001 From: aminecmi Date: Sat, 27 Aug 2022 13:06:16 +0200 Subject: [PATCH] Fixing a todo. --- .../bou/amine/apps/readerforselfossv2/utils/DateUtils.kt | 5 ++--- .../bou/amine/apps/readerforselfossv2/utils/DateUtils.kt | 4 +++- .../bou/amine/apps/readerforselfossv2/utils/DateUtils.kt | 2 +- .../bou/amine/apps/readerforselfossv2/utils/DateUtils.kt | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/shared/src/androidMain/kotlin/bou/amine/apps/readerforselfossv2/utils/DateUtils.kt b/shared/src/androidMain/kotlin/bou/amine/apps/readerforselfossv2/utils/DateUtils.kt index 15cfb94..62668c6 100644 --- a/shared/src/androidMain/kotlin/bou/amine/apps/readerforselfossv2/utils/DateUtils.kt +++ b/shared/src/androidMain/kotlin/bou/amine/apps/readerforselfossv2/utils/DateUtils.kt @@ -8,14 +8,13 @@ import java.time.OffsetDateTime import java.time.ZoneOffset import java.time.format.DateTimeFormatter -actual class DateUtils actual constructor(appSettingsService: AppSettingsService) { - val ads: AppSettingsService = appSettingsService // TODO: why is this needed now ? +actual class DateUtils actual constructor(actual val appSettingsService: AppSettingsService) { actual fun parseDate(dateString: String): Long { val FORMATTERV1 = "yyyy-MM-dd HH:mm:ss" - return if (ads.getApiVersion() >= 4) { + return if (appSettingsService.getApiVersion() >= 4) { OffsetDateTime.parse(dateString).toInstant().toEpochMilli() } else { LocalDateTime.parse(dateString, DateTimeFormatter.ofPattern(FORMATTERV1)).toInstant( diff --git a/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/utils/DateUtils.kt b/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/utils/DateUtils.kt index 35ecfa5..d235b97 100644 --- a/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/utils/DateUtils.kt +++ b/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/utils/DateUtils.kt @@ -7,7 +7,9 @@ import bou.amine.apps.readerforselfossv2.service.AppSettingsService fun SelfossModel.Item.parseDate(dateUtils: DateUtils): Long = dateUtils.parseDate(this.datetime) -expect class DateUtils(appSettingsService: AppSettingsService) { +expect class DateUtils constructor(appSettingsService: AppSettingsService) { + val appSettingsService: AppSettingsService // This is needed because of https://stackoverflow.com/a/65249085 + fun parseDate(dateString: String): Long fun parseRelativeDate(dateString: String): String diff --git a/shared/src/iosArm64Main/kotlin/bou/amine/apps/readerforselfossv2/utils/DateUtils.kt b/shared/src/iosArm64Main/kotlin/bou/amine/apps/readerforselfossv2/utils/DateUtils.kt index b217356..b55ec14 100644 --- a/shared/src/iosArm64Main/kotlin/bou/amine/apps/readerforselfossv2/utils/DateUtils.kt +++ b/shared/src/iosArm64Main/kotlin/bou/amine/apps/readerforselfossv2/utils/DateUtils.kt @@ -2,7 +2,7 @@ package bou.amine.apps.readerforselfossv2.utils import bou.amine.apps.readerforselfossv2.service.AppSettingsService -actual class DateUtils actual constructor(appSettingsService: AppSettingsService) { +actual class DateUtils actual constructor(actual val appSettingsService: AppSettingsService) { actual fun parseDate(dateString: String): Long { TODO("Not yet implemented") } diff --git a/shared/src/iosX64Main/kotlin/bou/amine/apps/readerforselfossv2/utils/DateUtils.kt b/shared/src/iosX64Main/kotlin/bou/amine/apps/readerforselfossv2/utils/DateUtils.kt index b217356..b55ec14 100644 --- a/shared/src/iosX64Main/kotlin/bou/amine/apps/readerforselfossv2/utils/DateUtils.kt +++ b/shared/src/iosX64Main/kotlin/bou/amine/apps/readerforselfossv2/utils/DateUtils.kt @@ -2,7 +2,7 @@ package bou.amine.apps.readerforselfossv2.utils import bou.amine.apps.readerforselfossv2.service.AppSettingsService -actual class DateUtils actual constructor(appSettingsService: AppSettingsService) { +actual class DateUtils actual constructor(actual val appSettingsService: AppSettingsService) { actual fun parseDate(dateString: String): Long { TODO("Not yet implemented") }