commonMain.com.paoapps.fifi.serialization.LocalTimeSerializer.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of fifi-common Show documentation
Show all versions of fifi-common Show documentation
Kotlin Multiplatform Mobile framework for optimal code sharing between iOS and Android.
The newest version!
package com.paoapps.fifi.serialization
import kotlinx.datetime.LocalTime
import kotlinx.serialization.KSerializer
import kotlinx.serialization.descriptors.PrimitiveKind
import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor
import kotlinx.serialization.encoding.Decoder
import kotlinx.serialization.encoding.Encoder
//object LocalTimeSerializer: KSerializer {
// override val descriptor = PrimitiveSerialDescriptor("LocalTime", PrimitiveKind.STRING)
//
// override fun serialize(encoder: Encoder, value: LocalTime) {
// encoder.encodeString(value.format())
// }
//
// override fun deserialize(decoder: Decoder): LocalTime {
// val parts = decoder.decodeString().split(":")
// val hours = parts[0].toInt()
// val minutes = parts[1].toInt()
// return LocalTime(hours, minutes)
// }
//}