:mega: The next release of `kotlinx-datetime` will...
# kotlinx-datetime
d
📣 The next release of
kotlinx-datetime
will include a breaking change without an automatic migration path! • Currently,
TimeZone.toString()
returns
TimeZone.id
. For example,
TimeZone.of("Europe/Berlin").toString() == "Europe/Berlin"
. • After the change,
toString
will include additional information to help you debug where the timezone data is coming from, in an unspecified format. For example,
TimeZoneContext.System.get("Europe/Berlin").toString()
could be
Europe/Berlin[JVM]
, or
JvmTimeZone(Europe/Berlin)
, or
TimeZone(TimeZoneContext.System, Europe/Berlin)
. Please review your usages of
TimeZone.toString()
and see if you need to replace them with explicit calls to `id`:
TimeZoneContext.System.get("Europe/Berlin").id == "Europe/Berlin"
will continue to work like it did. The purpose of this breaking change is to allow you to easily distinguish between time zones obtained from
TimeZoneContext.System
and
TimeZoneContext.Bundled
and potentially, custom timezone databases. We don't encourage mixing several timezone databases in one code base—and would therefore like to help you notice a mixup when it does happen by accident.
👍 11
👍🏾 1
u
A quick question, if you consider this breaking is depending on Instant/LocalDateTime/LocalDate.toString to output ISO formatted string a good idea? I always considered toString to be opaque, but I'm noticing this library seems to think of it differently?
d
There are several layers to this! 1. No, it's not opaque. Usually, you may rely on what's written in the documentation. kotlinlang.org/api/kotlinx-datetime/…/to-string.html does document that
timeZone.toString() == timeZone.id
, so we're breaking a literal written promise. 2. We made no promises yet!
kotlinx-datetime
is marked as experimental, so we reserve the right to break anything at any moment until 1.0. In theory, if you're only going by formal written contracts, you shouldn't trust anything we currently say about the behavior of
kotlinx-datetime
. 3. We try our best not to bother you anyway. Library authors should think twice before changing any aspect of behavior, even an unspecified one, if it can be realistically expected that people rely on it. Not creating pointless extra work on a library version bump is important. We take this principle so seriously that people often forget that
kotlinx-datetime
is experimental at all.
➕ 1