Introduce APIs for dependency injection of TimeZone-related information#610
Introduce APIs for dependency injection of TimeZone-related information#610dkhalanskyjb wants to merge 14 commits into
Conversation
swankjesse
left a comment
There was a problem hiding this comment.
This is fantastic and I appreciate how much design effort went into this.
When I set up servers and CI environments and such I always set an environment variable TZ=UTC0 so the host machine’s zone doesn’t accidentally leak through to the application layer. For example, I don’t need to worry that payment scheduling will change due to DST.
Would you consider exposing a symbol similar to TimeZoneContext.System like TimeZoneContext.Universal that is locked to UTC?
Note: this is just an interface at this point and will not compile.
|
|
087e12a to
7a159cb
Compare
7a159cb to
10fac52
Compare
| public final class kotlinx/datetime/TimeZoneContext$Companion { | ||
| } | ||
|
|
||
| public final class kotlinx/datetime/TimeZoneContext$DefaultImpls { |
There was a problem hiding this comment.
Since this is a new API, can it use the new mechanism of default function compilation which relies on JVM default methods? This old trampoline-based version is only needed for existing APIs targeted by old code.
Fixes #17
Fixes #201
Fixes #435
#611 is a space for comments, questions, and suggestions. Since the PR is at the conceptual stage, some discussion threads may end up being quite long, so the PR format is not particularly well-suited for it.
The most interesting places in the code are:
TimeZonewill look like with its static functions now deprecated. Note the updated semantics of==, which now takes theTimeZone's origin timezone databases into account.kotlinx-datetimeone will be able to depend on to obtain an up-to-date timezone database.It's important to note that this is not a full-fledged solution for providing custom timezone databases, though! Constructing a custom
TimeZoneis still going to be non-viable, even with the proposed API, as there's no way to construct a customTimeZone. To properly implement that, we would (most likely) need to expose the structure of aTimeZoneobject (historical data, recurring rules) and the additional logic that is likely going to be needed when implementing realistic timezone databases (seekotlinx-datetime/timezones/full/common/src/BundledTimeZoneContext.kt
Lines 84 to 96 in e550556