Skip to content

Commit

Permalink
Adding serializers for OffsetDateTime and LocalTime
Browse files Browse the repository at this point in the history
  • Loading branch information
Kantis committed Oct 26, 2022
1 parent 79a4d23 commit 58d32cd
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package io.ks3.java.time

import io.ks3.standard.stringSerializer
import kotlinx.serialization.KSerializer
import kotlinx.serialization.Serializable
import java.time.LocalTime

typealias LocalTimeAsString = @Serializable(with = LocalTimeAsStringSerializer::class) LocalTime

object LocalTimeAsStringSerializer : KSerializer<LocalTime> by stringSerializer(
LocalTimeAsStringSerializer::class.qualifiedName!!,
LocalTime::parse,
LocalTime::toString,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package io.ks3.java.time

import io.ks3.standard.stringSerializer
import kotlinx.serialization.KSerializer
import kotlinx.serialization.Serializable
import java.time.OffsetDateTime

typealias OffsetDateTimeAsString = @Serializable(with = OffsetDateTimeAsStringSerializer::class) OffsetDateTime

object OffsetDateTimeAsStringSerializer : KSerializer<OffsetDateTime> by stringSerializer(
OffsetDateTimeAsStringSerializer::class.qualifiedName!!,
OffsetDateTime::parse,
OffsetDateTime::toString,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package io.ks3.java.time

import io.kotest.core.spec.style.FreeSpec
import io.kotest.property.Arb
import io.kotest.property.arbitrary.localTime
import io.ks3.test.generateSerializerTests

class LocalTimeAsStringSerializerTests: FreeSpec(
{
include(generateSerializerTests(LocalTimeAsStringSerializer, Arb.localTime()))
}
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package io.ks3.java.time

import io.kotest.core.spec.style.FreeSpec
import io.kotest.property.Arb
import io.kotest.property.arbitrary.localTime
import io.ks3.test.generateSerializerTests

class OffsetDateTimeAsStringSerializerTests: FreeSpec(
{
include(generateSerializerTests(LocalTimeAsStringSerializer, Arb.localTime()))
}
)

0 comments on commit 58d32cd

Please sign in to comment.