mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2024-12-26 02:27:14 +00:00
add klock in common and DateTimeSerializer
This commit is contained in:
parent
2db0eadbfe
commit
9f7c963cd5
@ -2,6 +2,10 @@
|
|||||||
|
|
||||||
## 0.20.46
|
## 0.20.46
|
||||||
|
|
||||||
|
* `Common`:
|
||||||
|
* Now this repo depends on `klock`
|
||||||
|
* Add new object-serializer `DateTimeSerializer` for `klock` serializer
|
||||||
|
|
||||||
## 0.20.45
|
## 0.20.45
|
||||||
|
|
||||||
* `Versions`:
|
* `Versions`:
|
||||||
|
@ -8,6 +8,11 @@ apply from: "$mppJvmJsAndroidLinuxMingwLinuxArm64ProjectPresetPath"
|
|||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
sourceSets {
|
sourceSets {
|
||||||
|
commonMain {
|
||||||
|
dependencies {
|
||||||
|
api libs.klock
|
||||||
|
}
|
||||||
|
}
|
||||||
jvmMain {
|
jvmMain {
|
||||||
dependencies {
|
dependencies {
|
||||||
api project(":micro_utils.coroutines")
|
api project(":micro_utils.coroutines")
|
||||||
|
@ -0,0 +1,23 @@
|
|||||||
|
package dev.inmo.micro_utils.common
|
||||||
|
|
||||||
|
import korlibs.time.DateTime
|
||||||
|
import kotlinx.serialization.KSerializer
|
||||||
|
import kotlinx.serialization.Serializer
|
||||||
|
import kotlinx.serialization.builtins.serializer
|
||||||
|
import kotlinx.serialization.descriptors.SerialDescriptor
|
||||||
|
import kotlinx.serialization.encoding.Decoder
|
||||||
|
import kotlinx.serialization.encoding.Encoder
|
||||||
|
|
||||||
|
@Serializer(DateTime::class)
|
||||||
|
object DateTimeSerializer : KSerializer<DateTime> {
|
||||||
|
override val descriptor: SerialDescriptor
|
||||||
|
get() = Double.serializer().descriptor
|
||||||
|
|
||||||
|
override fun deserialize(decoder: Decoder): DateTime {
|
||||||
|
return DateTime(decoder.decodeDouble())
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun serialize(encoder: Encoder, value: DateTime) {
|
||||||
|
encoder.encodeDouble(value.unixMillis)
|
||||||
|
}
|
||||||
|
}
|
@ -12,7 +12,6 @@ kotlin {
|
|||||||
dependencies {
|
dependencies {
|
||||||
api internalProject("micro_utils.common")
|
api internalProject("micro_utils.common")
|
||||||
api libs.kt.serialization.cbor
|
api libs.kt.serialization.cbor
|
||||||
api libs.klock
|
|
||||||
api libs.uuid
|
api libs.uuid
|
||||||
api libs.ktor.io
|
api libs.ktor.io
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user