@@ -88,6 +88,9 @@ internal fun readTzFile(data: ByteArray): TzFile {
88
88
override fun toString (): String = " Ttinfo(utoff=$utoff , isdst=$isdst , abbrind=$abbrind )"
89
89
}
90
90
91
+ fun abbreviationForIndex (abbreviations : List <Byte >, startIndex : UByte ): String = abbreviations.drop(startIndex.toInt())
92
+ .takeWhile { byte -> byte != 0 .toByte() }.toByteArray().decodeToString()
93
+
91
94
inline fun BinaryDataReader.readData (header : Header , readTime : () -> Long ): TzFileData {
92
95
val transitionTimes = List (header.timecnt) { readTime() }
93
96
val transitionTypes = List (header.timecnt) { readByte() }
@@ -99,8 +102,6 @@ internal fun readTzFile(data: ByteArray): TzFile {
99
102
)
100
103
}
101
104
val abbreviations = List (header.charcnt) { readByte() }
102
- fun abbreviationForIndex (startIndex : UByte ): String = abbreviations.drop(startIndex.toInt())
103
- .takeWhile { byte -> byte != 0 .toByte() }.toByteArray().decodeToString()
104
105
val leapSecondRules = List (header.leapcnt) {
105
106
TzFileData .LeapSecondRule (
106
107
readTime(),
@@ -114,7 +115,7 @@ internal fun readTzFile(data: ByteArray): TzFile {
114
115
return TzFileData (
115
116
leapSecondRules,
116
117
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)) }
118
119
)
119
120
}
120
121
0 commit comments