File tree Expand file tree Collapse file tree 2 files changed +20
-3
lines changed
core/commonKotlin/src/internal Expand file tree Collapse file tree 2 files changed +20
-3
lines changed Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright 2019-2025 JetBrains s.r.o. and contributors.
3
+ * Use of this source code is governed by the Apache 2.0 License that can be found in the LICENSE.txt file.
4
+ */
5
+
6
+ package kotlinx.datetime.internal
7
+
8
+ import kotlinx.datetime.Instant
9
+ import kotlinx.datetime.LocalDateTime
10
+ import kotlinx.datetime.UtcOffset
11
+
12
+ internal interface TimeZoneRules {
13
+
14
+ fun infoAtInstant (instant : Instant ): UtcOffset
15
+
16
+ fun infoAtDatetime (localDateTime : LocalDateTime ): OffsetInfo
17
+ }
Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ internal class TimeZoneRulesCommon(
28
28
* [recurringZoneRules].
29
29
*/
30
30
val recurringZoneRules : RecurringZoneRules ? ,
31
- ) {
31
+ ) : TimeZoneRules {
32
32
init {
33
33
require(offsets.size == transitionEpochSeconds.size + 1 ) {
34
34
" offsets.size must be one more than transitionEpochSeconds.size"
@@ -65,7 +65,7 @@ internal class TimeZoneRulesCommon(
65
65
}
66
66
}
67
67
68
- fun infoAtInstant (instant : Instant ): UtcOffset {
68
+ override fun infoAtInstant (instant : Instant ): UtcOffset {
69
69
val epochSeconds = instant.epochSeconds
70
70
// good: no transitions, or instant is after the last transition
71
71
if (recurringZoneRules != null && transitionEpochSeconds.lastOrNull()?.let { epochSeconds >= it } != false ) {
@@ -81,7 +81,7 @@ internal class TimeZoneRulesCommon(
81
81
return offsets[index]
82
82
}
83
83
84
- fun infoAtDatetime (localDateTime : LocalDateTime ): OffsetInfo {
84
+ override fun infoAtDatetime (localDateTime : LocalDateTime ): OffsetInfo {
85
85
if (recurringZoneRules != null && transitionLocalDateTimes.lastOrNull()?.let { localDateTime > it } != false ) {
86
86
return recurringZoneRules.infoAtLocalDateTime(localDateTime, offsets.last())
87
87
}
You can’t perform that action at this time.
0 commit comments