Skip to content

Commit 3eff33a

Browse files
committed
Attempt 2
1 parent 4a2b3cf commit 3eff33a

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

core/windows/src/internal/TzdbInRegistry.kt

+5-2
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,19 @@ internal class TzdbInRegistry: TimeZoneDatabase {
6060
}
6161
}
6262
}
63-
offsets.lastOrNull()?.let { lastOffset ->
63+
val lastOffset = offsets.lastOrNull()
64+
if (lastOffset == null) {
65+
offsets.add(recurring.offsetAtYearStart())
66+
} else {
6467
/* If there are already some offsets, we can not add a new offset without defining a transition to
6568
it. The moment when we start using the recurring rules is the first year that does not have any
6669
historic data provided. */
6770
val firstYearWithRecurringRules = historic.last().first + 1
6871
val newYearInLastOffset = LocalDate(firstYearWithRecurringRules, Month.JANUARY, 1).atTime(0, 0)
6972
.toInstant(lastOffset)
7073
transitionEpochSeconds.add(newYearInLastOffset.epochSeconds)
74+
offsets.add(offsets.last())
7175
}
72-
offsets.add(recurring.offsetAtYearStart())
7376
TimeZoneRules(transitionEpochSeconds, offsets, recurringRules)
7477
}
7578
put(name, rules)

0 commit comments

Comments
 (0)