Skip to content

Commit 49dd802

Browse files
committed
Remove the no-longer-needed JS Joda entries
1 parent 36062a7 commit 49dd802

10 files changed

+33
-1281
lines changed

core/commonJs/src/JSJodaExceptions.kt

Lines changed: 0 additions & 14 deletions
This file was deleted.

core/commonJs/src/PlatformSpecifics.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
package kotlinx.datetime.internal
77

88
// a pair of ZoneRulesProvider.asDynamic().getTzdbData().zones and ZoneRulesProvider.asDynamic().getTzdbData().links
9-
internal expect fun readTzdb(): Pair<List<String>, List<String>>
9+
internal expect fun readTzdb(): Pair<List<String>, List<String>>?
1010

1111
public expect interface InteropInterface
1212

core/commonJs/src/internal/Platform.kt

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
103116
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
105118

106119
internal actual fun currentTime(): Instant = Instant.fromEpochMilliseconds(Date().getTime().toLong())
107120

core/commonJs/src/kotlinx.datetime.internal.JSJoda.module_@js-joda_core._aliases.kt

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)