Skip to content

feat(core): support kotlinx.datetime.Instant#478

Open
kangwooc wants to merge 1 commit intoavro-kotlin:mainfrom
kangwooc:main
Open

feat(core): support kotlinx.datetime.Instant#478
kangwooc wants to merge 1 commit intoavro-kotlin:mainfrom
kangwooc:main

Conversation

@kangwooc
Copy link
Copy Markdown
Contributor

Summary

  • Add native serializer support for kotlinx.datetime.Instant.
  • Encode as timestamp-millis by default, with writer-schema support for timestamp-micros, timestamp-nanos, and ISO-8601 strings.
  • Update the public API dump and reject out-of-range Avro nanos timestamps instead of overflowing.

Testing

  • ./gradlew :core:test --tests '*KotlinInstantEncodingTest' --tests '*KotlinInstantDecodingTest' :core:apiCheck
  • ./gradlew check

Closes #417

Add native support for kotlinx.datetime.Instant so users can encode and decode Kotlin Instant values without registering a contextual serializer manually.

The serializer defaults to Avro timestamp-millis, supports writer-schema selection of timestamp-micros and timestamp-nanos, and still allows ISO-8601 strings through @AvroStringable. Nanos conversion uses checked arithmetic so out-of-range instants fail instead of silently wrapping into unrelated timestamps.

Constraint: Issue avro-kotlin#417 requests Kotlin Instant support with timestamp millis, micros, and nanos support

Constraint: binary-compatibility-validator requires the new public serializer in core/api/core.api

Rejected: Keep the overflow fix as a separate review commit | the PR should present this feature as one coherent change

Confidence: high

Scope-risk: narrow

Tested: ./gradlew :core:test --tests '*KotlinInstantEncodingTest' --tests '*KotlinInstantDecodingTest' :core:apiCheck

Tested: ./gradlew check
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Provide kotlin.time.Instant serializer

1 participant