-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use formatters by kotlinx.datetime instead of ones from java time
- Loading branch information
1 parent
c65481f
commit 07fd02b
Showing
15 changed files
with
306 additions
and
262 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 22 additions & 30 deletions
52
src/cds/plugins/cats/src/main/kotlin/org/icpclive/cds/plugins/cats/CATSDataSource.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
...cds/utils/src/main/kotlin/org/icpclive/cds/util/serializers/FormatterInstantSerializer.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package org.icpclive.cds.util.serializers | ||
|
||
import kotlinx.datetime.* | ||
import kotlinx.datetime.format.DateTimeComponents | ||
import kotlinx.datetime.format.DateTimeFormat | ||
import kotlinx.serialization.KSerializer | ||
import kotlinx.serialization.descriptors.* | ||
import kotlinx.serialization.encoding.Decoder | ||
import kotlinx.serialization.encoding.Encoder | ||
|
||
public abstract class FormatterInstantSerializer(private val formatter: DateTimeFormat<DateTimeComponents>) : KSerializer<Instant> { | ||
override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor("Instant", PrimitiveKind.STRING) | ||
override fun serialize(encoder: Encoder, value: Instant) { | ||
encoder.encodeString(value.format(formatter, TimeZone.currentSystemDefault().offsetAt(value))) | ||
} | ||
override fun deserialize(decoder: Decoder): Instant { | ||
return Instant.parse(decoder.decodeString(), formatter) | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...s/utils/src/main/kotlin/org/icpclive/cds/util/serializers/FormatterLocalDateSerializer.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package org.icpclive.cds.util.serializers | ||
|
||
import kotlinx.datetime.LocalDateTime | ||
import kotlinx.datetime.format.DateTimeFormat | ||
import kotlinx.serialization.KSerializer | ||
import kotlinx.serialization.descriptors.* | ||
import kotlinx.serialization.encoding.Decoder | ||
import kotlinx.serialization.encoding.Encoder | ||
|
||
public abstract class FormatterLocalDateSerializer(private val formatter: DateTimeFormat<LocalDateTime>) : KSerializer<LocalDateTime> { | ||
override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor("LocalDateTime", PrimitiveKind.STRING) | ||
override fun serialize(encoder: Encoder, value: LocalDateTime) { | ||
encoder.encodeString(formatter.format(value)) | ||
} | ||
override fun deserialize(decoder: Decoder): LocalDateTime { | ||
return formatter.parse(decoder.decodeString()) | ||
} | ||
} |
Oops, something went wrong.