@@ -71,7 +71,7 @@ private fun parseTzdb(): TimeZoneDatabase {
71
71
fun List<Long>.partialSums (): List <Long > = scanWithoutInitial(0 , Long ::plus)
72
72
73
73
val zones = mutableMapOf<String , TimeZoneRules >()
74
- val (zonesPacked, linksPacked) = readTzdb()
74
+ val (zonesPacked, linksPacked) = readTzdb() ? : return EmptyTimeZoneDatabase
75
75
for (zone in zonesPacked) {
76
76
val components = zone.split(' |' )
77
77
val offsets = components[2 ].split(' ' ).map { unpackBase60(it) }
@@ -100,8 +100,21 @@ private fun parseTzdb(): TimeZoneDatabase {
100
100
}
101
101
}
102
102
103
+ private object EmptyTimeZoneDatabase : TimeZoneDatabase {
104
+ override fun rulesForId (id : String ): TimeZoneRules = when (id) {
105
+ " SYSTEM" -> TimeZoneRules (
106
+ transitionEpochSeconds = emptyList(),
107
+ offsets = listOf (UtcOffset .ZERO ),
108
+ recurringZoneRules = null
109
+ ) // TODO: that's not correct, we need to use `Date()`'s offset
110
+ else -> throw IllegalTimeZoneException (" JSJoda timezone database is not available" )
111
+ }
112
+
113
+ override fun availableTimeZoneIds (): Set <String > = emptySet()
114
+ }
115
+
103
116
internal actual fun currentSystemDefaultZone (): Pair <String , TimeZoneRules ?> =
104
- ZoneId .systemDefault().id() to null // TODO: make this function with SYSTEM
117
+ ZoneId .systemDefault().id() to null
105
118
106
119
internal actual fun currentTime (): Instant = Instant .fromEpochMilliseconds(Date ().getTime().toLong())
107
120
0 commit comments