Skip to content

Commit 8efcd34

Browse files
lunakolyFenstonSingel
authored andcommitted
[migration to Kotlin 2.2.20] Update Kotlin code w.r.t. KT-77986
1 parent 4d0e348 commit 8efcd34

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

core/commonKotlin/src/internal/Tzfile.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ internal fun readTzFile(data: ByteArray): TzFile {
8888
override fun toString(): String = "Ttinfo(utoff=$utoff, isdst=$isdst, abbrind=$abbrind)"
8989
}
9090

91+
fun abbreviationForIndex(abbreviations: List<Byte>, startIndex: UByte): String = abbreviations.drop(startIndex.toInt())
92+
.takeWhile { byte -> byte != 0.toByte() }.toByteArray().decodeToString()
93+
9194
inline fun BinaryDataReader.readData(header: Header, readTime: () -> Long): TzFileData {
9295
val transitionTimes = List(header.timecnt) { readTime() }
9396
val transitionTypes = List(header.timecnt) { readByte() }
@@ -99,8 +102,6 @@ internal fun readTzFile(data: ByteArray): TzFile {
99102
)
100103
}
101104
val abbreviations = List(header.charcnt) { readByte() }
102-
fun abbreviationForIndex(startIndex: UByte): String = abbreviations.drop(startIndex.toInt())
103-
.takeWhile { byte -> byte != 0.toByte() }.toByteArray().decodeToString()
104105
val leapSecondRules = List(header.leapcnt) {
105106
TzFileData.LeapSecondRule(
106107
readTime(),
@@ -114,7 +115,7 @@ internal fun readTzFile(data: ByteArray): TzFile {
114115
return TzFileData(
115116
leapSecondRules,
116117
transitionTimes.zip(transitionTypes) { time, type -> TzFileData.Transition(time, type.toInt()) },
117-
ttinfos.map { TzFileData.ClockState(TzFileOffset(it.utoff), it.isdst, abbreviationForIndex(it.abbrind)) }
118+
ttinfos.map { TzFileData.ClockState(TzFileOffset(it.utoff), it.isdst, abbreviationForIndex(abbreviations, it.abbrind)) }
118119
)
119120
}
120121

0 commit comments

Comments
 (0)