@@ -60,19 +60,16 @@ internal class TzdbInRegistry: TimeZoneDatabase {
60
60
}
61
61
}
62
62
}
63
- val lastOffset = offsets.lastOrNull()
64
- if (lastOffset == null ) {
65
- offsets.add(recurring.offsetAtYearStart())
66
- } else {
63
+ offsets.lastOrNull()?.let { lastOffset ->
67
64
/* If there are already some offsets, we can not add a new offset without defining a transition to
68
65
it. The moment when we start using the recurring rules is the first year that does not have any
69
66
historic data provided. */
70
67
val firstYearWithRecurringRules = historic.last().first + 1
71
68
val newYearInLastOffset = LocalDate (firstYearWithRecurringRules, Month .JANUARY , 1 ).atTime(0 , 0 )
72
69
.toInstant(lastOffset)
73
70
transitionEpochSeconds.add(newYearInLastOffset.epochSeconds)
74
- offsets.add(offsets.last())
75
71
}
72
+ offsets.add(recurring.offsetAtYearStart())
76
73
TimeZoneRules (transitionEpochSeconds, offsets, recurringRules)
77
74
}
78
75
put(name, rules)
@@ -335,7 +332,9 @@ private class PerYearZoneRulesDataWithTransitions(
335
332
val standardTransition get() =
336
333
RecurringZoneRules .Rule (standardTransitionTime, offsetBefore = daylightOffset, offsetAfter = standardOffset)
337
334
338
- override fun offsetAtYearStart (): UtcOffset = standardOffset // TODO: not true in all years + all zones
335
+ override fun offsetAtYearStart (): UtcOffset =
336
+ if (daylightTransitionTime.toLocalDateTime(2030 ) < standardTransitionTime.toLocalDateTime(2030 ))
337
+ standardOffset else daylightOffset
339
338
340
339
override fun toString (): String = " standard offset is $standardOffset " +
341
340
" , daylight offset is $daylightOffset " +
0 commit comments