mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2024-11-18 22:33:49 +00:00
Merge pull request #100 from InsanusMokrassar/0.7.0
0.7.0 + migration back to klock
This commit is contained in:
commit
c7a53846ad
@ -2,6 +2,13 @@
|
||||
|
||||
## 0.6.0
|
||||
|
||||
**THIS VERSION HAS MIGRATED FROM KOTLINX DATETIME TO KORLIBS KLOCK. CAREFUL**
|
||||
|
||||
* `Versions`
|
||||
* `kotlinx.datetime` -> `Klock`
|
||||
|
||||
## 0.6.0 DO NOT RECOMMENDED
|
||||
|
||||
**THIS VERSION HAS MIGRATED FROM KORLIBS KLOCK TO KOTLINX DATETIME. CAREFUL**
|
||||
**ALL DEPRECATION HAVE BEEN REMOVED**
|
||||
|
||||
|
@ -14,7 +14,7 @@ kotlin_exposed_version=0.35.1
|
||||
|
||||
ktor_version=1.6.4
|
||||
|
||||
datetime_version=0.3.0
|
||||
klockVersion=2.4.3
|
||||
|
||||
github_release_plugin_version=2.2.12
|
||||
|
||||
@ -45,5 +45,5 @@ dokka_version=1.5.30
|
||||
# Project data
|
||||
|
||||
group=dev.inmo
|
||||
version=0.6.0
|
||||
android_code_version=73
|
||||
version=0.7.0
|
||||
android_code_version=74
|
||||
|
@ -11,7 +11,7 @@ kotlin {
|
||||
commonMain {
|
||||
dependencies {
|
||||
api "org.jetbrains.kotlinx:kotlinx-serialization-cbor:$kotlin_serialisation_core_version"
|
||||
api "org.jetbrains.kotlinx:kotlinx-datetime:$datetime_version"
|
||||
api "com.soywiz.korlibs.klock:klock:$klockVersion"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,17 +1,17 @@
|
||||
package dev.inmo.micro_utils.ktor.common
|
||||
|
||||
import kotlinx.datetime.Instant
|
||||
import com.soywiz.klock.DateTime
|
||||
|
||||
typealias FromToDateTime = Pair<Instant?, Instant?>
|
||||
typealias FromToDateTime = Pair<DateTime?, DateTime?>
|
||||
|
||||
val FromToDateTime.asFromToUrlPart: QueryParams
|
||||
get() = mapOf(
|
||||
"from" to first ?.toEpochMilliseconds() ?.toString(),
|
||||
"to" to second ?.toEpochMilliseconds() ?.toString()
|
||||
"from" to first ?.unixMillis ?.toString(),
|
||||
"to" to second ?.unixMillis ?.toString()
|
||||
)
|
||||
|
||||
val QueryParams.extractFromToDateTime: FromToDateTime
|
||||
get() = FromToDateTime(
|
||||
get("from") ?.run { toLongOrNull() ?: (toDoubleOrNull() ?.toLong()) } ?.let { Instant.fromEpochMilliseconds(it) },
|
||||
get("to") ?.run { toLongOrNull() ?: (toDoubleOrNull() ?.toLong()) } ?.let { Instant.fromEpochMilliseconds(it) }
|
||||
get("from") ?.toDoubleOrNull() ?.let { DateTime(it) },
|
||||
get("to") ?.toDoubleOrNull() ?.let { DateTime(it) }
|
||||
)
|
||||
|
@ -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") ?.run { toLongOrNull() ?: (toDoubleOrNull() ?.toLong()) } ?.let { Instant.fromEpochMilliseconds(it) },
|
||||
get("to") ?.run { toLongOrNull() ?: (toDoubleOrNull() ?.toLong()) } ?.let { Instant.fromEpochMilliseconds(it) }
|
||||
get("from") ?.toDoubleOrNull() ?.let { DateTime(it) },
|
||||
get("to") ?.toDoubleOrNull() ?.let { DateTime(it) }
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user