Skip to content

Conversation

@dkhalanskyjb
Copy link
Collaborator

  • Remove the @kotlinx.serialization.Serializable annotation from TimeZone and FixedOffsetTimeZone.
  • Deprecate TimeZoneSerializer and FixedOffsetTimeZoneSerializer with a warning.
  • Introduce and deprecate the .serializer() functions in their companion objects with a warning. Previously, this function used to be generated by the kotlinx.serialization compiler plugin.

Fixes #576

* Remove the `@kotlinx.serialization.Serializable`
  annotation from `TimeZone` and `FixedOffsetTimeZone`.
* Deprecate `TimeZoneSerializer`
  and `FixedOffsetTimeZoneSerializer`
  with a warning.
* Introduce and deprecate the `.serializer()`
  functions in their companion objects with a warning.
  Previously, this function used to be generated by the
  `kotlinx.serialization` compiler plugin.

Fixes #576
@@ -1,12 +1,11 @@
/*
* Copyright 2019-2021 JetBrains s.r.o.
* Copyright 2025 JetBrains s.r.o.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC, we can leave only the start date, not the end date

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can remove the copyright notices completely: Kotlin/kotlinx.coroutines#4016

* JSON example: `"Europe/Berlin"`
*/
@Deprecated(
"Serializing TimeZone is discouraged. Please serialize the id String instead.",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

id String sounds weird. Maybe you want id: String? Or since this is more of a text message, string id sounds better IMO

* @sample kotlinx.datetime.test.samples.TimeZoneSamples.usage
*/
@Serializable(with = TimeZoneSerializer::class)
public expect open class TimeZone {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that the moment you remove @Serializable(with=...) annotation from type, it is shown as red with SERIALIZER_NOT_FOUND where it was used in any @Serializable user class. Sadly, we do not have any kind of deprecation migration for that; so I suggest raising all @Deprecated here to ERROR just to speedup this process

Copy link
Collaborator Author

@dkhalanskyjb dkhalanskyjb Nov 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea is to keep it WARNING for now so that people can work around the SERIALIZER_NOT_FOUND issue by adding their own annotation to the TimeZone field. Then, after a migratory period, when we expect such annotations to be removed as well, the deprecation can be promoted to ERROR.

Does this approach make sense?

@Deprecated("Use offset.totalSeconds", ReplaceWith("offset.totalSeconds"))
public val totalSeconds: Int

/** @suppress */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suppress what?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The generation of the KDoc for this object.

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.

Remove TimeZone and FixedOffsetTimeZone serialization

4 participants