Skip to content

Commit 5c196df

Browse files
committed
Improve the documentation
1 parent 5b3515e commit 5c196df

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

core/commonMain/src/kotlinx/serialization/builtins/BuiltinSerializers.kt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,15 +247,20 @@ public fun UShort.Companion.serializer(): KSerializer<UShort> = UShortSerializer
247247

248248
/**
249249
* Returns serializer for [Duration].
250-
* It is serialized as a string that represents a duration in the ISO-8601-2 format.
250+
* It is serialized as a string that represents a duration in the format used by [Duration.toIsoString],
251+
* that is, the ISO-8601-2 format.
251252
*
252-
* The result of serialization is similar to calling [Duration.toIsoString], for deserialization is [Duration.parseIsoString].
253+
* For deserialization, [Duration.parseIsoString] is used.
254+
*
255+
* @see Duration.toIsoString
256+
* @see Duration.parseIsoString
253257
*/
254258
public fun Duration.Companion.serializer(): KSerializer<Duration> = DurationSerializer
255259

256260
/**
257261
* Returns serializer for [Instant].
258-
* It is serialized as a string that represents an instant in the format described in ISO-8601-1:2019, 5.4.2.1b).
262+
* It is serialized as a string that represents an instant in the format used by [Instant.toString]
263+
* and described in ISO-8601-1:2019, 5.4.2.1b).
259264
*
260265
* Deserialization is case-insensitive.
261266
* More details can be found in the documentation of [Instant.toString] and [Instant.parse] functions.

core/commonMain/src/kotlinx/serialization/builtins/InstantComponentSerializer.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ import kotlinx.serialization.encoding.*
1010
import kotlin.time.ExperimentalTime
1111
import kotlin.time.Instant
1212

13+
/**
14+
* Serializer that encodes and decodes [Instant] as its second and nanosecond components of the Unix time.
15+
*
16+
* JSON example: `{"epochSeconds":1607505416,"nanosecondsOfSecond":124000}`.
17+
*/
1318
@ExperimentalTime
1419
public object InstantComponentSerializer : KSerializer<Instant> {
1520

0 commit comments

Comments
 (0)