All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.com.paoapps.fifi.serialization.LocalTimeSerializer.kt Maven / Gradle / Ivy

Go to download

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)
//    }
//}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy