@@ -71,7 +71,7 @@ private fun parseTzdb(): TimeZoneDatabase {
7171 fun List<Long>.partialSums (): List <Long > = scanWithoutInitial(0 , Long ::plus)
7272
7373 val zones = mutableMapOf<String , TimeZoneRules >()
74- val (zonesPacked, linksPacked) = readTzdb()
74+ val (zonesPacked, linksPacked) = readTzdb() ? : return EmptyTimeZoneDatabase
7575 for (zone in zonesPacked) {
7676 val components = zone.split(' |' )
7777 val offsets = components[2 ].split(' ' ).map { unpackBase60(it) }
@@ -100,8 +100,21 @@ private fun parseTzdb(): TimeZoneDatabase {
100100 }
101101}
102102
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+
103116internal actual fun currentSystemDefaultZone (): Pair <String , TimeZoneRules ?> =
104- ZoneId .systemDefault().id() to null // TODO: make this function with SYSTEM
117+ ZoneId .systemDefault().id() to null
105118
106119internal actual fun currentTime (): Instant = Instant .fromEpochMilliseconds(Date ().getTime().toLong())
107120
0 commit comments