From 2a783f6e2b5e6ce0633a33845d041aa1bd213beb Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sun, 3 Oct 2021 18:58:06 +0600 Subject: [PATCH 1/2] start 0.6.0 --- CHANGELOG.md | 2 ++ gradle.properties | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b930764945..56c34c5a7da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # Changelog +## 0.6.0 + ## 0.5.31 * `Versions`: diff --git a/gradle.properties b/gradle.properties index 7ff8d810460..a952987e2ec 100644 --- a/gradle.properties +++ b/gradle.properties @@ -45,5 +45,5 @@ dokka_version=1.5.30 # Project data group=dev.inmo -version=0.5.31 -android_code_version=72 +version=0.6.0 +android_code_version=73 From 44e26ccb4f6d7526afe6bc993918d14982f13ccd Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 4 Oct 2021 15:54:43 +0600 Subject: [PATCH 2/2] migration onto datetime --- CHANGELOG.md | 5 +++++ gradle.properties | 2 +- ktor/common/build.gradle | 2 +- .../micro_utils/ktor/common/FromToDateTimeUrl.kt | 12 ++++++------ .../micro_utils/ktor/server/FromToDateTimeInUrl.kt | 6 +++--- 5 files changed, 16 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 56c34c5a7da..46d40335218 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ ## 0.6.0 +**THIS VERSION HAS MIGRATED FROM KORLIBS KLOCK TO KOTLINX DATETIME. CAREFUL** + +* `Versions` + * `Klock` -> `kotlinx.datetime` + ## 0.5.31 * `Versions`: diff --git a/gradle.properties b/gradle.properties index a952987e2ec..99cc3adc782 100644 --- a/gradle.properties +++ b/gradle.properties @@ -14,7 +14,7 @@ kotlin_exposed_version=0.35.1 ktor_version=1.6.4 -klockVersion=2.4.3 +datetime_version=0.3.0 github_release_plugin_version=2.2.12 diff --git a/ktor/common/build.gradle b/ktor/common/build.gradle index 64cbbd21ac2..bed7d491035 100644 --- a/ktor/common/build.gradle +++ b/ktor/common/build.gradle @@ -11,7 +11,7 @@ kotlin { commonMain { dependencies { api "org.jetbrains.kotlinx:kotlinx-serialization-cbor:$kotlin_serialisation_core_version" - api "com.soywiz.korlibs.klock:klock:$klockVersion" + api "org.jetbrains.kotlinx:kotlinx-datetime:$datetime_version" } } } diff --git a/ktor/common/src/commonMain/kotlin/dev/inmo/micro_utils/ktor/common/FromToDateTimeUrl.kt b/ktor/common/src/commonMain/kotlin/dev/inmo/micro_utils/ktor/common/FromToDateTimeUrl.kt index ff015524268..a83cfee0743 100644 --- a/ktor/common/src/commonMain/kotlin/dev/inmo/micro_utils/ktor/common/FromToDateTimeUrl.kt +++ b/ktor/common/src/commonMain/kotlin/dev/inmo/micro_utils/ktor/common/FromToDateTimeUrl.kt @@ -1,17 +1,17 @@ package dev.inmo.micro_utils.ktor.common -import com.soywiz.klock.DateTime +import kotlinx.datetime.Instant -typealias FromToDateTime = Pair +typealias FromToDateTime = Pair val FromToDateTime.asFromToUrlPart: QueryParams get() = mapOf( - "from" to first ?.unixMillis ?.toString(), - "to" to second ?.unixMillis ?.toString() + "from" to first ?.toEpochMilliseconds() ?.toString(), + "to" to second ?.toEpochMilliseconds() ?.toString() ) val QueryParams.extractFromToDateTime: FromToDateTime get() = FromToDateTime( - get("from") ?.toDoubleOrNull() ?.let { DateTime(it) }, - get("to") ?.toDoubleOrNull() ?.let { DateTime(it) } + get("from") ?.run { toLongOrNull() ?: (toDoubleOrNull() ?.toLong()) } ?.let { Instant.fromEpochMilliseconds(it) }, + get("to") ?.run { toLongOrNull() ?: (toDoubleOrNull() ?.toLong()) } ?.let { Instant.fromEpochMilliseconds(it) } ) diff --git a/ktor/server/src/jvmMain/kotlin/dev/inmo/micro_utils/ktor/server/FromToDateTimeInUrl.kt b/ktor/server/src/jvmMain/kotlin/dev/inmo/micro_utils/ktor/server/FromToDateTimeInUrl.kt index c7e850a9bfd..045b196d84c 100644 --- a/ktor/server/src/jvmMain/kotlin/dev/inmo/micro_utils/ktor/server/FromToDateTimeInUrl.kt +++ b/ktor/server/src/jvmMain/kotlin/dev/inmo/micro_utils/ktor/server/FromToDateTimeInUrl.kt @@ -1,11 +1,11 @@ package dev.inmo.micro_utils.ktor.server -import com.soywiz.klock.DateTime import dev.inmo.micro_utils.ktor.common.FromToDateTime import io.ktor.http.Parameters +import kotlinx.datetime.Instant val Parameters.extractFromToDateTime: FromToDateTime get() = FromToDateTime( - get("from") ?.toDoubleOrNull() ?.let { DateTime(it) }, - get("to") ?.toDoubleOrNull() ?.let { DateTime(it) } + get("from") ?.run { toLongOrNull() ?: (toDoubleOrNull() ?.toLong()) } ?.let { Instant.fromEpochMilliseconds(it) }, + get("to") ?.run { toLongOrNull() ?: (toDoubleOrNull() ?.toLong()) } ?.let { Instant.fromEpochMilliseconds(it) } )