diff --git a/build.gradle.kts b/build.gradle.kts index c71749d2..70a49005 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -34,3 +34,9 @@ allprojects { compilerOptions { freeCompilerArgs.add("-Xpartial-linkage-loglevel=ERROR") } } } + +// Disable NPM to NodeJS nightly compatibility check. +// Drop this when NodeJs version that supports latest Wasm become stable +tasks.withType().configureEach { + args.add("--ignore-engines") +} diff --git a/core/build.gradle.kts b/core/build.gradle.kts index b0a51001..4ee77b45 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -1,7 +1,6 @@ import kotlinx.team.infra.mavenPublicationsPom import org.jetbrains.kotlin.gradle.tasks.KotlinCompile import java.net.URL -import java.util.Locale import javax.xml.parsers.DocumentBuilderFactory import java.io.ByteArrayOutputStream import java.io.PrintWriter @@ -107,6 +106,16 @@ kotlin { // } } + wasmJs { + nodejs { + testTask { + useMocha { + timeout = "30s" + } + } + } + } + sourceSets.all { val suffixIndex = name.indexOfLast { it.isUpperCase() } val targetName = name.substring(0, suffixIndex) @@ -193,20 +202,37 @@ kotlin { } } - val jsMain by getting { + val commonJsMain by creating { + dependsOn(commonMain.get()) dependencies { - api("org.jetbrains.kotlin:kotlin-stdlib-js") api("org.jetbrains.kotlinx:kotlinx-serialization-core:$serializationVersion") implementation(npm("@js-joda/core", "3.2.0")) } } - val jsTest by getting { + val commonJsTest by creating { + dependsOn(commonTest.get()) dependencies { implementation(npm("@js-joda/timezone", "2.3.0")) } } + val jsMain by getting { + dependsOn(commonJsMain) + } + + val jsTest by getting { + dependsOn(commonJsTest) + } + + val wasmJsMain by getting { + dependsOn(commonJsMain) + } + + val wasmJsTest by getting { + dependsOn(commonJsTest) + } + val nativeMain by getting { dependsOn(commonMain.get()) dependencies { @@ -383,3 +409,18 @@ tasks.withType().configureEach { } } } + +// Disable intermediate sourceSet compilation because we do not need js-wasmJs artifact +tasks.configureEach { + if (name == "compileCommonJsMainKotlinMetadata") { + enabled = false + } +} + +// Drop this configuration when the Node.JS version in KGP will support wasm gc milestone 4 +// check it here: +// https://github.com/JetBrains/kotlin/blob/master/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/nodejs/NodeJsRootExtension.kt +with(org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin.apply(rootProject)) { + nodeVersion = "21.0.0-v8-canary202309167e82ab1fa2" + nodeDownloadBaseUrl = "https://nodejs.org/download/v8-canary" +} \ No newline at end of file diff --git a/core/common/src/serializers/DateTimeUnitSerializers.kt b/core/common/src/serializers/DateTimeUnitSerializers.kt index a115a2db..f003d9bf 100644 --- a/core/common/src/serializers/DateTimeUnitSerializers.kt +++ b/core/common/src/serializers/DateTimeUnitSerializers.kt @@ -21,8 +21,11 @@ import kotlin.reflect.KClass */ public object TimeBasedDateTimeUnitSerializer: KSerializer { - override val descriptor: SerialDescriptor = buildClassSerialDescriptor("TimeBased") { - element("nanoseconds") + // https://youtrack.jetbrains.com/issue/KT-63939 + override val descriptor: SerialDescriptor by lazy(LazyThreadSafetyMode.PUBLICATION) { + buildClassSerialDescriptor("TimeBased") { + element("nanoseconds") + } } override fun serialize(encoder: Encoder, value: DateTimeUnit.TimeBased) { @@ -65,8 +68,11 @@ public object TimeBasedDateTimeUnitSerializer: KSerializer { - override val descriptor: SerialDescriptor = buildClassSerialDescriptor("DayBased") { - element("days") + // https://youtrack.jetbrains.com/issue/KT-63939 + override val descriptor: SerialDescriptor by lazy(LazyThreadSafetyMode.PUBLICATION) { + buildClassSerialDescriptor("DayBased") { + element("days") + } } override fun serialize(encoder: Encoder, value: DateTimeUnit.DayBased) { @@ -109,8 +115,11 @@ public object DayBasedDateTimeUnitSerializer: KSerializer */ public object MonthBasedDateTimeUnitSerializer: KSerializer { - override val descriptor: SerialDescriptor = buildClassSerialDescriptor("MonthBased") { - element("months") + // https://youtrack.jetbrains.com/issue/KT-63939 + override val descriptor: SerialDescriptor by lazy(LazyThreadSafetyMode.PUBLICATION) { + buildClassSerialDescriptor("MonthBased") { + element("months") + } } override fun serialize(encoder: Encoder, value: DateTimeUnit.MonthBased) { @@ -155,10 +164,13 @@ public object MonthBasedDateTimeUnitSerializer: KSerializer() { - private val impl = SealedClassSerializer("kotlinx.datetime.DateTimeUnit.DateBased", - DateTimeUnit.DateBased::class, - arrayOf(DateTimeUnit.DayBased::class, DateTimeUnit.MonthBased::class), - arrayOf(DayBasedDateTimeUnitSerializer, MonthBasedDateTimeUnitSerializer)) + // https://youtrack.jetbrains.com/issue/KT-63939 + private val impl by lazy(LazyThreadSafetyMode.PUBLICATION) { + SealedClassSerializer("kotlinx.datetime.DateTimeUnit.DateBased", + DateTimeUnit.DateBased::class, + arrayOf(DateTimeUnit.DayBased::class, DateTimeUnit.MonthBased::class), + arrayOf(DayBasedDateTimeUnitSerializer, MonthBasedDateTimeUnitSerializer)) + } @InternalSerializationApi override fun findPolymorphicSerializerOrNull(decoder: CompositeDecoder, klassName: String?): @@ -189,10 +201,13 @@ public object DateBasedDateTimeUnitSerializer: AbstractPolymorphicSerializer() { - private val impl = SealedClassSerializer("kotlinx.datetime.DateTimeUnit", - DateTimeUnit::class, - arrayOf(DateTimeUnit.DayBased::class, DateTimeUnit.MonthBased::class, DateTimeUnit.TimeBased::class), - arrayOf(DayBasedDateTimeUnitSerializer, MonthBasedDateTimeUnitSerializer, TimeBasedDateTimeUnitSerializer)) + // https://youtrack.jetbrains.com/issue/KT-63939 + private val impl by lazy(LazyThreadSafetyMode.PUBLICATION) { + SealedClassSerializer("kotlinx.datetime.DateTimeUnit", + DateTimeUnit::class, + arrayOf(DateTimeUnit.DayBased::class, DateTimeUnit.MonthBased::class, DateTimeUnit.TimeBased::class), + arrayOf(DayBasedDateTimeUnitSerializer, MonthBasedDateTimeUnitSerializer, TimeBasedDateTimeUnitSerializer)) + } @InternalSerializationApi override fun findPolymorphicSerializerOrNull(decoder: CompositeDecoder, klassName: String?): DeserializationStrategy? = @@ -209,4 +224,4 @@ public object DateTimeUnitSerializer: AbstractPolymorphicSerializer 0) MAX else MIN } public actual fun fromEpochSeconds(epochSeconds: Long, nanosecondAdjustment: Int): Instant = try { - Instant(jtInstant.ofEpochSecond(epochSeconds, nanosecondAdjustment)) + Instant(jsTry { jtInstant.ofEpochSecond(epochSeconds.toDouble(), nanosecondAdjustment) }) } catch (e: Throwable) { if (!e.isJodaDateTimeException()) throw e if (epochSeconds > 0) MAX else MIN } - public actual val DISTANT_PAST: Instant = Instant(jtInstant.ofEpochSecond(DISTANT_PAST_SECONDS, 999_999_999)) - public actual val DISTANT_FUTURE: Instant = Instant(jtInstant.ofEpochSecond(DISTANT_FUTURE_SECONDS, 0)) + public actual val DISTANT_PAST: Instant = Instant(jsTry { jtInstant.ofEpochSecond(DISTANT_PAST_SECONDS.toDouble(), 999_999_999) }) + public actual val DISTANT_FUTURE: Instant = Instant(jsTry { jtInstant.ofEpochSecond(DISTANT_FUTURE_SECONDS.toDouble(), 0) }) internal actual val MIN: Instant = Instant(jtInstant.MIN) internal actual val MAX: Instant = Instant(jtInstant.MAX) @@ -120,23 +120,23 @@ public actual class Instant internal constructor(internal val value: jtInstant) public actual fun Instant.plus(period: DateTimePeriod, timeZone: TimeZone): Instant = try { - val thisZdt = this.value.atZone(timeZone.zoneId) + val thisZdt = jsTry { this.value.atZone(timeZone.zoneId) } with(period) { thisZdt - .run { if (totalMonths != 0) plusMonths(totalMonths) else this } - .run { if (days != 0) plusDays(days) else this } - .run { if (hours != 0) plusHours(hours) else this } - .run { if (minutes != 0) plusMinutes(minutes) else this } - .run { if (seconds != 0) plusSeconds(seconds) else this } - .run { if (nanoseconds != 0) plusNanos(nanoseconds.toDouble()) else this } + .run { if (totalMonths != 0) jsTry { plusMonths(totalMonths) } else this } + .run { if (days != 0) jsTry { plusDays(days) } else this } + .run { if (hours != 0) jsTry { plusHours(hours) } else this } + .run { if (minutes != 0) jsTry { plusMinutes(minutes) } else this } + .run { if (seconds != 0) jsTry { plusSeconds(seconds) } else this } + .run { if (nanoseconds != 0) jsTry { plusNanos(nanoseconds.toDouble()) } else this } }.toInstant().let(::Instant) } catch (e: Throwable) { if (e.isJodaDateTimeException()) throw DateTimeArithmeticException(e) throw e } -private fun Instant.atZone(zone: TimeZone): ZonedDateTime = value.atZone(zone.zoneId) -private fun jtInstant.checkZone(zone: TimeZone): jtInstant = apply { atZone(zone.zoneId) } +private fun Instant.atZone(zone: TimeZone): jtZonedDateTime = jsTry { value.atZone(zone.zoneId) } +private fun jtInstant.checkZone(zone: TimeZone): jtInstant = apply { jsTry { atZone(zone.zoneId) } } @Deprecated("Use the plus overload with an explicit number of units", ReplaceWith("this.plus(1, unit, timeZone)")) public actual fun Instant.plus(unit: DateTimeUnit, timeZone: TimeZone): Instant = @@ -150,9 +150,9 @@ public actual fun Instant.plus(value: Long, unit: DateTimeUnit, timeZone: TimeZo plus(value, unit).value.checkZone(timeZone) } is DateTimeUnit.DayBased -> - thisZdt.plusDays(value.toDouble() * unit.days).toInstant() + jsTry {thisZdt.plusDays(value.toDouble() * unit.days) }.toInstant() is DateTimeUnit.MonthBased -> - thisZdt.plusMonths(value.toDouble() * unit.months).toInstant() + jsTry { thisZdt.plusMonths(value.toDouble() * unit.months) }.toInstant() }.let(::Instant) } catch (e: Throwable) { if (e.isJodaDateTimeException()) throw DateTimeArithmeticException(e) @@ -166,9 +166,9 @@ public actual fun Instant.plus(value: Int, unit: DateTimeUnit, timeZone: TimeZon is DateTimeUnit.TimeBased -> plus(value.toLong(), unit).value.checkZone(timeZone) is DateTimeUnit.DayBased -> - thisZdt.plusDays(value.toDouble() * unit.days).toInstant() + jsTry { thisZdt.plusDays(value.toDouble() * unit.days) }.toInstant() is DateTimeUnit.MonthBased -> - thisZdt.plusMonths(value.toDouble() * unit.months).toInstant() + jsTry { thisZdt.plusMonths(value.toDouble() * unit.months) }.toInstant() }.let(::Instant) } catch (e: Throwable) { if (e.isJodaDateTimeException()) throw DateTimeArithmeticException(e) @@ -194,12 +194,12 @@ public actual fun Instant.plus(value: Long, unit: DateTimeUnit.TimeBased): Insta } public actual fun Instant.periodUntil(other: Instant, timeZone: TimeZone): DateTimePeriod = try { - var thisZdt = this.value.atZone(timeZone.zoneId) - val otherZdt = other.value.atZone(timeZone.zoneId) + var thisZdt = jsTry { this.value.atZone(timeZone.zoneId) } + val otherZdt = jsTry { other.value.atZone(timeZone.zoneId) } - val months = thisZdt.until(otherZdt, ChronoUnit.MONTHS).toDouble(); thisZdt = thisZdt.plusMonths(months) - val days = thisZdt.until(otherZdt, ChronoUnit.DAYS).toDouble(); thisZdt = thisZdt.plusDays(days) - val nanoseconds = thisZdt.until(otherZdt, ChronoUnit.NANOS).toDouble() + val months = thisZdt.until(otherZdt, jtChronoUnit.MONTHS); thisZdt = jsTry { thisZdt.plusMonths(months) } + val days = thisZdt.until(otherZdt, jtChronoUnit.DAYS); thisZdt = jsTry { thisZdt.plusDays(days) } + val nanoseconds = thisZdt.until(otherZdt, jtChronoUnit.NANOS) buildDateTimePeriod(months.toInt(), days.toInt(), nanoseconds.toLong()) } catch (e: Throwable) { @@ -211,8 +211,8 @@ public actual fun Instant.until(other: Instant, unit: DateTimeUnit, timeZone: Ti val otherZdt = other.atZone(timeZone) when(unit) { is DateTimeUnit.TimeBased -> until(other, unit) - is DateTimeUnit.DayBased -> (thisZdt.until(otherZdt, ChronoUnit.DAYS).toDouble() / unit.days).toLong() - is DateTimeUnit.MonthBased -> (thisZdt.until(otherZdt, ChronoUnit.MONTHS).toDouble() / unit.months).toLong() + is DateTimeUnit.DayBased -> (thisZdt.until(otherZdt, jtChronoUnit.DAYS) / unit.days).toLong() + is DateTimeUnit.MonthBased -> (thisZdt.until(otherZdt, jtChronoUnit.MONTHS) / unit.months).toLong() } } catch (e: ArithmeticException) { if (this < other) Long.MAX_VALUE else Long.MIN_VALUE @@ -221,4 +221,4 @@ public actual fun Instant.until(other: Instant, unit: DateTimeUnit, timeZone: Ti } internal actual fun Instant.toStringWithOffset(offset: UtcOffset): String = - jtOffsetDateTime.ofInstant(this.value, offset.zoneOffset).toString() + jtOffsetDateTime.ofInstant(this.value, offset.zoneOffset).toString() \ No newline at end of file diff --git a/core/commonJs/src/JSJodaExceptions.kt b/core/commonJs/src/JSJodaExceptions.kt new file mode 100644 index 00000000..0b854d1a --- /dev/null +++ b/core/commonJs/src/JSJodaExceptions.kt @@ -0,0 +1,14 @@ +/* + * Copyright 2019-2023 JetBrains s.r.o. and contributors. + * Use of this source code is governed by the Apache 2.0 License that can be found in the LICENSE.txt file. + */ + +package kotlinx.datetime + +internal fun Throwable.isJodaArithmeticException(): Boolean = hasJsExceptionName("ArithmeticException") +internal fun Throwable.isJodaDateTimeException(): Boolean = hasJsExceptionName("DateTimeException") +internal fun Throwable.isJodaDateTimeParseException(): Boolean = hasJsExceptionName("DateTimeParseException") + +internal expect fun Throwable.hasJsExceptionName(name: String): Boolean + +internal expect inline fun jsTry(crossinline body: () -> T): T \ No newline at end of file diff --git a/core/js/src/LocalDate.kt b/core/commonJs/src/LocalDate.kt similarity index 74% rename from core/js/src/LocalDate.kt rename to core/commonJs/src/LocalDate.kt index 4348ff30..30a2dd8f 100644 --- a/core/js/src/LocalDate.kt +++ b/core/commonJs/src/LocalDate.kt @@ -5,16 +5,16 @@ package kotlinx.datetime -import kotlinx.datetime.internal.JSJoda.ChronoUnit import kotlinx.datetime.serializers.LocalDateIso8601Serializer import kotlinx.serialization.Serializable import kotlinx.datetime.internal.JSJoda.LocalDate as jtLocalDate +import kotlinx.datetime.internal.JSJoda.ChronoUnit as jtChronoUnit @Serializable(with = LocalDateIso8601Serializer::class) public actual class LocalDate internal constructor(internal val value: jtLocalDate) : Comparable { public actual companion object { public actual fun parse(isoString: String): LocalDate = try { - jtLocalDate.parse(isoString).let(::LocalDate) + jsTry { jtLocalDate.parse(isoString) }.let(::LocalDate) } catch (e: Throwable) { if (e.isJodaDateTimeParseException()) throw DateTimeFormatException(e) throw e @@ -24,7 +24,7 @@ public actual class LocalDate internal constructor(internal val value: jtLocalDa internal actual val MAX: LocalDate = LocalDate(jtLocalDate.MAX) public actual fun fromEpochDays(epochDays: Int): LocalDate = try { - LocalDate(jtLocalDate.ofEpochDay(epochDays)) + LocalDate(jsTry { jtLocalDate.ofEpochDay(epochDays) }) } catch (e: Throwable) { if (e.isJodaDateTimeException()) throw IllegalArgumentException(e) throw e @@ -33,7 +33,7 @@ public actual class LocalDate internal constructor(internal val value: jtLocalDa public actual constructor(year: Int, monthNumber: Int, dayOfMonth: Int) : this(try { - jtLocalDate.of(year, monthNumber, dayOfMonth) + jsTry { jtLocalDate.of(year, monthNumber, dayOfMonth) } } catch (e: Throwable) { if (e.isJodaDateTimeException()) throw IllegalArgumentException(e) throw e @@ -41,21 +41,21 @@ public actual class LocalDate internal constructor(internal val value: jtLocalDa public actual constructor(year: Int, month: Month, dayOfMonth: Int) : this(year, month.number, dayOfMonth) - public actual val year: Int get() = value.year().toInt() - public actual val monthNumber: Int get() = value.monthValue().toInt() + public actual val year: Int get() = value.year() + public actual val monthNumber: Int get() = value.monthValue() public actual val month: Month get() = value.month().toMonth() - public actual val dayOfMonth: Int get() = value.dayOfMonth().toInt() + public actual val dayOfMonth: Int get() = value.dayOfMonth() public actual val dayOfWeek: DayOfWeek get() = value.dayOfWeek().toDayOfWeek() - public actual val dayOfYear: Int get() = value.dayOfYear().toInt() + public actual val dayOfYear: Int get() = value.dayOfYear() override fun equals(other: Any?): Boolean = - (this === other) || (other is LocalDate && this.value == other.value) + (this === other) || (other is LocalDate && (this.value === other.value || this.value.equals(other.value))) - override fun hashCode(): Int = value.hashCode().toInt() + override fun hashCode(): Int = value.hashCode() actual override fun toString(): String = value.toString() - actual override fun compareTo(other: LocalDate): Int = this.value.compareTo(other.value).toInt() + actual override fun compareTo(other: LocalDate): Int = this.value.compareTo(other.value) public actual fun toEpochDays(): Int = value.toEpochDay().toInt() } @@ -69,8 +69,8 @@ public actual fun LocalDate.plus(value: Long, unit: DateTimeUnit.DateBased): Loc private fun LocalDate.plusNumber(value: Number, unit: DateTimeUnit.DateBased): LocalDate = try { when (unit) { - is DateTimeUnit.DayBased -> this.value.plusDays(value.toDouble() * unit.days) - is DateTimeUnit.MonthBased -> this.value.plusMonths(value.toDouble() * unit.months) + is DateTimeUnit.DayBased -> jsTry { this.value.plusDays((value.toDouble() * unit.days).toInt()) } + is DateTimeUnit.MonthBased -> jsTry { this.value.plusMonths((value.toDouble() * unit.months).toInt()) } }.let(::LocalDate) } catch (e: Throwable) { if (!e.isJodaDateTimeException() && !e.isJodaArithmeticException()) throw e @@ -81,8 +81,8 @@ private fun LocalDate.plusNumber(value: Number, unit: DateTimeUnit.DateBased): L public actual operator fun LocalDate.plus(period: DatePeriod): LocalDate = try { with(period) { return@with value - .run { if (totalMonths != 0) plusMonths(totalMonths) else this } - .run { if (days != 0) plusDays(days) else this } + .run { if (totalMonths != 0) jsTry { plusMonths(totalMonths) } else this } + .run { if (days != 0) jsTry { plusDays(days) } else this } }.let(::LocalDate) } catch (e: Throwable) { @@ -95,8 +95,8 @@ public actual operator fun LocalDate.plus(period: DatePeriod): LocalDate = try { public actual fun LocalDate.periodUntil(other: LocalDate): DatePeriod { var startD = this.value val endD = other.value - val months = startD.until(endD, ChronoUnit.MONTHS).toInt(); startD = startD.plusMonths(months) - val days = startD.until(endD, ChronoUnit.DAYS).toInt() + val months = startD.until(endD, jtChronoUnit.MONTHS).toInt(); startD = jsTry { startD.plusMonths(months) } + val days = startD.until(endD, jtChronoUnit.DAYS).toInt() return DatePeriod(totalMonths = months, days) } @@ -107,10 +107,10 @@ public actual fun LocalDate.until(other: LocalDate, unit: DateTimeUnit.DateBased } public actual fun LocalDate.daysUntil(other: LocalDate): Int = - this.value.until(other.value, ChronoUnit.DAYS).toInt() + this.value.until(other.value, jtChronoUnit.DAYS).toInt() public actual fun LocalDate.monthsUntil(other: LocalDate): Int = - this.value.until(other.value, ChronoUnit.MONTHS).toInt() + this.value.until(other.value, jtChronoUnit.MONTHS).toInt() public actual fun LocalDate.yearsUntil(other: LocalDate): Int = - this.value.until(other.value, ChronoUnit.YEARS).toInt() + this.value.until(other.value, jtChronoUnit.YEARS).toInt() diff --git a/core/js/src/LocalDateTime.kt b/core/commonJs/src/LocalDateTime.kt similarity index 75% rename from core/js/src/LocalDateTime.kt rename to core/commonJs/src/LocalDateTime.kt index b635e4f7..ca266a48 100644 --- a/core/js/src/LocalDateTime.kt +++ b/core/commonJs/src/LocalDateTime.kt @@ -13,7 +13,7 @@ public actual class LocalDateTime internal constructor(internal val value: jtLoc public actual constructor(year: Int, monthNumber: Int, dayOfMonth: Int, hour: Int, minute: Int, second: Int, nanosecond: Int) : this(try { - jtLocalDateTime.of(year, monthNumber, dayOfMonth, hour, minute, second, nanosecond) + jsTry { jtLocalDateTime.of(year, monthNumber, dayOfMonth, hour, minute, second, nanosecond) } } catch (e: Throwable) { if (e.isJodaDateTimeException()) throw IllegalArgumentException(e) throw e @@ -23,18 +23,18 @@ public actual class LocalDateTime internal constructor(internal val value: jtLoc this(year, month.number, dayOfMonth, hour, minute, second, nanosecond) public actual constructor(date: LocalDate, time: LocalTime) : - this(jtLocalDateTime.of(date.value, time.value)) + this(jsTry { jtLocalDateTime.of(date.value, time.value) }) - public actual val year: Int get() = value.year().toInt() - public actual val monthNumber: Int get() = value.monthValue().toInt() + public actual val year: Int get() = value.year() + public actual val monthNumber: Int get() = value.monthValue() public actual val month: Month get() = value.month().toMonth() - public actual val dayOfMonth: Int get() = value.dayOfMonth().toInt() + public actual val dayOfMonth: Int get() = value.dayOfMonth() public actual val dayOfWeek: DayOfWeek get() = value.dayOfWeek().toDayOfWeek() - public actual val dayOfYear: Int get() = value.dayOfYear().toInt() + public actual val dayOfYear: Int get() = value.dayOfYear() - public actual val hour: Int get() = value.hour().toInt() - public actual val minute: Int get() = value.minute().toInt() - public actual val second: Int get() = value.second().toInt() + public actual val hour: Int get() = value.hour() + public actual val minute: Int get() = value.minute() + public actual val second: Int get() = value.second() public actual val nanosecond: Int get() = value.nano().toInt() public actual val date: LocalDate get() = LocalDate(value.toLocalDate()) // cache? @@ -42,17 +42,17 @@ public actual class LocalDateTime internal constructor(internal val value: jtLoc public actual val time: LocalTime get() = LocalTime(value.toLocalTime()) override fun equals(other: Any?): Boolean = - (this === other) || (other is LocalDateTime && this.value == other.value) + (this === other) || (other is LocalDateTime && (this.value === other.value || this.value.equals(other.value))) - override fun hashCode(): Int = value.hashCode().toInt() + override fun hashCode(): Int = value.hashCode() actual override fun toString(): String = value.toString() - actual override fun compareTo(other: LocalDateTime): Int = this.value.compareTo(other.value).toInt() + actual override fun compareTo(other: LocalDateTime): Int = this.value.compareTo(other.value) public actual companion object { public actual fun parse(isoString: String): LocalDateTime = try { - jtLocalDateTime.parse(isoString).let(::LocalDateTime) + jsTry { jtLocalDateTime.parse(isoString) }.let(::LocalDateTime) } catch (e: Throwable) { if (e.isJodaDateTimeParseException()) throw DateTimeFormatException(e) throw e @@ -62,5 +62,4 @@ public actual class LocalDateTime internal constructor(internal val value: jtLoc internal actual val MAX: LocalDateTime = LocalDateTime(jtLocalDateTime.MAX) } -} - +} \ No newline at end of file diff --git a/core/js/src/LocalTime.kt b/core/commonJs/src/LocalTime.kt similarity index 74% rename from core/js/src/LocalTime.kt rename to core/commonJs/src/LocalTime.kt index df1f749c..185d8795 100644 --- a/core/js/src/LocalTime.kt +++ b/core/commonJs/src/LocalTime.kt @@ -16,53 +16,53 @@ public actual class LocalTime internal constructor(internal val value: jtLocalTi public actual constructor(hour: Int, minute: Int, second: Int, nanosecond: Int) : this( try { - jtLocalTime.of(hour, minute, second, nanosecond) + jsTry { jtLocalTime.of(hour, minute, second, nanosecond) } } catch (e: Throwable) { if (e.isJodaDateTimeException()) throw IllegalArgumentException(e) throw e } ) - public actual val hour: Int get() = value.hour().toInt() - public actual val minute: Int get() = value.minute().toInt() - public actual val second: Int get() = value.second().toInt() + public actual val hour: Int get() = value.hour() + public actual val minute: Int get() = value.minute() + public actual val second: Int get() = value.second() public actual val nanosecond: Int get() = value.nano().toInt() - public actual fun toSecondOfDay(): Int = value.toSecondOfDay().toInt() - public actual fun toMillisecondOfDay(): Int = (value.toNanoOfDay().toDouble() / NANOS_PER_MILLI).toInt() + public actual fun toSecondOfDay(): Int = value.toSecondOfDay() + public actual fun toMillisecondOfDay(): Int = (value.toNanoOfDay() / NANOS_PER_MILLI).toInt() public actual fun toNanosecondOfDay(): Long = value.toNanoOfDay().toLong() override fun equals(other: Any?): Boolean = - (this === other) || (other is LocalTime && this.value == other.value) + (this === other) || (other is LocalTime && (this.value === other.value || this.value.equals(other.value))) - override fun hashCode(): Int = value.hashCode().toInt() + override fun hashCode(): Int = value.hashCode() actual override fun toString(): String = value.toString() - actual override fun compareTo(other: LocalTime): Int = this.value.compareTo(other.value).toInt() + actual override fun compareTo(other: LocalTime): Int = this.value.compareTo(other.value) public actual companion object { public actual fun parse(isoString: String): LocalTime = try { - jtLocalTime.parse(isoString).let(::LocalTime) + jsTry { jtLocalTime.parse(isoString) }.let(::LocalTime) } catch (e: Throwable) { if (e.isJodaDateTimeParseException()) throw DateTimeFormatException(e) throw e } public actual fun fromSecondOfDay(secondOfDay: Int): LocalTime = try { - jtLocalTime.ofSecondOfDay(secondOfDay, 0).let(::LocalTime) + jsTry { jtLocalTime.ofSecondOfDay(secondOfDay, 0) }.let(::LocalTime) } catch (e: Throwable) { throw IllegalArgumentException(e) } public actual fun fromMillisecondOfDay(millisecondOfDay: Int): LocalTime = try { - jtLocalTime.ofNanoOfDay(millisecondOfDay * 1_000_000.0).let(::LocalTime) + jsTry { jtLocalTime.ofNanoOfDay(millisecondOfDay * 1_000_000.0) }.let(::LocalTime) } catch (e: Throwable) { throw IllegalArgumentException(e) } public actual fun fromNanosecondOfDay(nanosecondOfDay: Long): LocalTime = try { // number of nanoseconds in a day is much less than `Number.MAX_SAFE_INTEGER`. - jtLocalTime.ofNanoOfDay(nanosecondOfDay.toDouble()).let(::LocalTime) + jsTry { jtLocalTime.ofNanoOfDay(nanosecondOfDay.toDouble()) }.let(::LocalTime) } catch (e: Throwable) { throw IllegalArgumentException(e) } @@ -70,4 +70,4 @@ public actual class LocalTime internal constructor(internal val value: jtLocalTi internal actual val MIN: LocalTime = LocalTime(jtLocalTime.MIN) internal actual val MAX: LocalTime = LocalTime(jtLocalTime.MAX) } -} +} \ No newline at end of file diff --git a/core/js/src/Month.kt b/core/commonJs/src/Month.kt similarity index 86% rename from core/js/src/Month.kt rename to core/commonJs/src/Month.kt index 17270f28..ae113dac 100644 --- a/core/js/src/Month.kt +++ b/core/commonJs/src/Month.kt @@ -22,4 +22,4 @@ public actual enum class Month { DECEMBER; } -internal fun jsMonth.toMonth(): Month = Month(this.value().toInt()) \ No newline at end of file +internal fun jsMonth.toMonth(): Month = Month(this.value()) \ No newline at end of file diff --git a/core/commonJs/src/PlatformSpecifics.kt b/core/commonJs/src/PlatformSpecifics.kt new file mode 100644 index 00000000..4bdd1c04 --- /dev/null +++ b/core/commonJs/src/PlatformSpecifics.kt @@ -0,0 +1,20 @@ +/* + * Copyright 2019-2023 JetBrains s.r.o. and contributors. + * Use of this source code is governed by the Apache 2.0 License that can be found in the LICENSE.txt file. + */ + +package kotlinx.datetime.internal + +internal expect fun getAvailableZoneIdsSet(): Set + +public expect interface InteropInterface + +@OptIn(ExperimentalMultiplatform::class) +@Retention(AnnotationRetention.BINARY) +@Target(AnnotationTarget.FILE) +@OptionalExpectation +public expect annotation class JsNonModule() + +@Retention(AnnotationRetention.BINARY) +@Target(AnnotationTarget.FILE) +public expect annotation class JsModule(val import: String) diff --git a/core/js/src/TimeZone.kt b/core/commonJs/src/TimeZone.kt similarity index 72% rename from core/js/src/TimeZone.kt rename to core/commonJs/src/TimeZone.kt index 86a645bd..a609c014 100644 --- a/core/js/src/TimeZone.kt +++ b/core/commonJs/src/TimeZone.kt @@ -4,13 +4,15 @@ */ package kotlinx.datetime -import kotlinx.datetime.serializers.* -import kotlinx.datetime.internal.JSJoda.ZoneId +import kotlinx.datetime.internal.JSJoda.LocalDateTime as jtLocalDateTime +import kotlinx.datetime.internal.JSJoda.ZoneId as jtZoneId import kotlinx.datetime.internal.JSJoda.ZoneOffset as jtZoneOffset +import kotlinx.datetime.internal.getAvailableZoneIdsSet +import kotlinx.datetime.serializers.* import kotlinx.serialization.Serializable @Serializable(with = TimeZoneSerializer::class) -public actual open class TimeZone internal constructor(internal val zoneId: ZoneId) { +public actual open class TimeZone internal constructor(internal val zoneId: jtZoneId) { public actual val id: String get() = zoneId.id() @@ -19,24 +21,24 @@ public actual open class TimeZone internal constructor(internal val zoneId: Zone public actual fun LocalDateTime.toInstant(): Instant = toInstant(this@TimeZone) override fun equals(other: Any?): Boolean = - (this === other) || (other is TimeZone && this.zoneId == other.zoneId) + (this === other) || (other is TimeZone && (this.zoneId === other.zoneId || this.zoneId.equals(other.zoneId))) - override fun hashCode(): Int = zoneId.hashCode().toInt() + override fun hashCode(): Int = zoneId.hashCode() override fun toString(): String = zoneId.toString() public actual companion object { - public actual fun currentSystemDefault(): TimeZone = ofZone(ZoneId.systemDefault()) + public actual fun currentSystemDefault(): TimeZone = ofZone(jtZoneId.systemDefault()) public actual val UTC: FixedOffsetTimeZone = UtcOffset(jtZoneOffset.UTC).asTimeZone() public actual fun of(zoneId: String): TimeZone = try { - ofZone(ZoneId.of(zoneId)) + ofZone(jsTry { jtZoneId.of(zoneId) }) } catch (e: Throwable) { if (e.isJodaDateTimeException()) throw IllegalTimeZoneException(e) throw e } - private fun ofZone(zoneId: ZoneId): TimeZone = when { + private fun ofZone(zoneId: jtZoneId): TimeZone = when { zoneId is jtZoneOffset -> FixedOffsetTimeZone(UtcOffset(zoneId)) zoneId.rules().isFixedOffset() -> @@ -45,15 +47,13 @@ public actual open class TimeZone internal constructor(internal val zoneId: Zone TimeZone(zoneId) } - - public actual val availableZoneIds: Set get() = ZoneId.getAvailableZoneIds().toSet() + public actual val availableZoneIds: Set get() = getAvailableZoneIdsSet() } } @Serializable(with = FixedOffsetTimeZoneSerializer::class) public actual class FixedOffsetTimeZone -internal constructor(public actual val offset: UtcOffset, zoneId: ZoneId): TimeZone(zoneId) { - +internal constructor(public actual val offset: UtcOffset, zoneId: jtZoneId): TimeZone(zoneId) { public actual constructor(offset: UtcOffset) : this(offset, offset.zoneOffset) @Deprecated("Use offset.totalSeconds", ReplaceWith("offset.totalSeconds")) @@ -62,22 +62,26 @@ internal constructor(public actual val offset: UtcOffset, zoneId: ZoneId): TimeZ public actual fun Instant.toLocalDateTime(timeZone: TimeZone): LocalDateTime = try { - kotlinx.datetime.internal.JSJoda.LocalDateTime.ofInstant(this.value, timeZone.zoneId).let(::LocalDateTime) + jsTry { jtLocalDateTime.ofInstant(this.value, timeZone.zoneId) }.let(::LocalDateTime) } catch (e: Throwable) { if (e.isJodaDateTimeException()) throw DateTimeArithmeticException(e) throw e } internal actual fun Instant.toLocalDateTime(offset: UtcOffset): LocalDateTime = try { - kotlinx.datetime.internal.JSJoda.LocalDateTime.ofInstant(this.value, offset.zoneOffset).let(::LocalDateTime) + jsTry { jtLocalDateTime.ofInstant(this.value, offset.zoneOffset) }.let(::LocalDateTime) } catch (e: Throwable) { if (e.isJodaDateTimeException()) throw DateTimeArithmeticException(e) throw e } - -public actual fun TimeZone.offsetAt(instant: Instant): UtcOffset = - zoneId.rules().offsetOfInstant(instant.value).let(::UtcOffset) +// throws DateTimeArithmeticException if the number of milliseconds is too large to represent as a safe int in JS +public actual fun TimeZone.offsetAt(instant: Instant): UtcOffset = try { + jsTry { zoneId.rules().offsetOfInstant(instant.value) }.let(::UtcOffset) +} catch (e: Throwable) { + if (e.isJodaArithmeticException()) throw DateTimeArithmeticException(e) + throw e +} public actual fun LocalDateTime.toInstant(timeZone: TimeZone): Instant = this.value.atZone(timeZone.zoneId).toInstant().let(::Instant) diff --git a/core/js/src/UtcOffset.kt b/core/commonJs/src/UtcOffset.kt similarity index 61% rename from core/js/src/UtcOffset.kt rename to core/commonJs/src/UtcOffset.kt index 31e36a53..89ca752e 100644 --- a/core/js/src/UtcOffset.kt +++ b/core/commonJs/src/UtcOffset.kt @@ -5,24 +5,24 @@ package kotlinx.datetime -import kotlinx.datetime.internal.JSJoda.ZoneOffset +import kotlinx.datetime.internal.JSJoda.ZoneOffset as jtZoneOffset import kotlinx.datetime.serializers.UtcOffsetSerializer import kotlinx.serialization.Serializable @Serializable(with = UtcOffsetSerializer::class) -public actual class UtcOffset(internal val zoneOffset: ZoneOffset) { - public actual val totalSeconds: Int get() = zoneOffset.totalSeconds().toInt() +public actual class UtcOffset internal constructor(internal val zoneOffset: jtZoneOffset) { + public actual val totalSeconds: Int get() = zoneOffset.totalSeconds() - override fun hashCode(): Int = zoneOffset.hashCode().toInt() - override fun equals(other: Any?): Boolean = other is UtcOffset && this.zoneOffset == other.zoneOffset + override fun hashCode(): Int = zoneOffset.hashCode() + override fun equals(other: Any?): Boolean = other is UtcOffset && (this.zoneOffset === other.zoneOffset || this.zoneOffset.equals(other.zoneOffset)) override fun toString(): String = zoneOffset.toString() public actual companion object { - public actual val ZERO: UtcOffset = UtcOffset(ZoneOffset.UTC) + public actual val ZERO: UtcOffset = UtcOffset(jtZoneOffset.UTC) public actual fun parse(offsetString: String): UtcOffset = try { - ZoneOffset.of(offsetString).let(::UtcOffset) + jsTry { jtZoneOffset.of(offsetString) }.let(::UtcOffset) } catch (e: Throwable) { if (e.isJodaDateTimeException()) throw DateTimeFormatException(e) throw e @@ -35,11 +35,11 @@ public actual fun UtcOffset(hours: Int? = null, minutes: Int? = null, seconds: I try { when { hours != null -> - UtcOffset(ZoneOffset.ofHoursMinutesSeconds(hours, minutes ?: 0, seconds ?: 0)) + UtcOffset(jsTry { jtZoneOffset.ofHoursMinutesSeconds(hours, minutes ?: 0, seconds ?: 0) }) minutes != null -> - UtcOffset(ZoneOffset.ofHoursMinutesSeconds(minutes / 60, minutes % 60, seconds ?: 0)) + UtcOffset(jsTry { jtZoneOffset.ofHoursMinutesSeconds(minutes / 60, minutes % 60, seconds ?: 0) }) else -> { - UtcOffset(ZoneOffset.ofTotalSeconds(seconds ?: 0)) + UtcOffset(jsTry { jtZoneOffset.ofTotalSeconds(seconds ?: 0) }) } } } catch (e: Throwable) { diff --git a/core/js/src/internal/mathJs.kt b/core/commonJs/src/internal/mathJs.kt similarity index 100% rename from core/js/src/internal/mathJs.kt rename to core/commonJs/src/internal/mathJs.kt diff --git a/core/commonJs/src/kotlinx.datetime.internal.JSJoda.module_@js-joda_core._aliases.kt b/core/commonJs/src/kotlinx.datetime.internal.JSJoda.module_@js-joda_core._aliases.kt new file mode 100644 index 00000000..5fadaa6a --- /dev/null +++ b/core/commonJs/src/kotlinx.datetime.internal.JSJoda.module_@js-joda_core._aliases.kt @@ -0,0 +1,8 @@ +@file:Suppress("NO_EXPLICIT_VISIBILITY_IN_API_MODE", "INTERFACE_WITH_SUPERCLASS", "OVERRIDING_FINAL_MEMBER", "RETURN_TYPE_MISMATCH_ON_OVERRIDE", "CONFLICTING_OVERLOADS", "EXTERNAL_DELEGATION") +package kotlinx.datetime.internal.JSJoda + +typealias Chronology = IsoChronology + +typealias DateTimeParseException = Error + +typealias DateTimeException = Error \ No newline at end of file diff --git a/core/commonJs/src/kotlinx.datetime.internal.JSJoda.module_@js-joda_core.kt b/core/commonJs/src/kotlinx.datetime.internal.JSJoda.module_@js-joda_core.kt new file mode 100644 index 00000000..a780b1e7 --- /dev/null +++ b/core/commonJs/src/kotlinx.datetime.internal.JSJoda.module_@js-joda_core.kt @@ -0,0 +1,1209 @@ +@file:kotlinx.datetime.internal.JsModule("@js-joda/core") +@file:kotlinx.datetime.internal.JsNonModule +@file:Suppress("NO_EXPLICIT_VISIBILITY_IN_API_MODE", "INTERFACE_WITH_SUPERCLASS", "OVERRIDING_FINAL_MEMBER", "RETURN_TYPE_MISMATCH_ON_OVERRIDE", "CONFLICTING_OVERLOADS", "PARAMETER_NAME_CHANGED_ON_OVERRIDE") +package kotlinx.datetime.internal.JSJoda + +import kotlinx.datetime.internal.InteropInterface +import kotlin.js.* + +external open class TemporalField : InteropInterface { + open fun isSupportedBy(temporal: TemporalAccessor): Boolean + open fun isDateBased(): Boolean + open fun isTimeBased(): Boolean + open fun baseUnit(): TemporalUnit + open fun rangeUnit(): TemporalUnit + open fun range(): ValueRange + open fun rangeRefinedBy(temporal: TemporalAccessor): ValueRange + open fun getFrom(temporal: TemporalAccessor): Int + open fun adjustInto(temporal: R, newValue: Int): R + open fun name(): String + open fun displayName(): String + open fun equals(other: InteropInterface): Boolean +} + +external open class TemporalUnit : InteropInterface { + open fun addTo(temporal: T, amount: Int): T + open fun between(temporal1: Temporal, temporal2: Temporal): Int + open fun duration(): Duration + open fun isDateBased(): Boolean + open fun isDurationEstimated(): Boolean + open fun isSupportedBy(temporal: Temporal): Boolean + open fun isTimeBased(): Boolean +} + +external open class ValueRange : InteropInterface { + open fun checkValidValue(value: Int, field: TemporalField): Int + open fun checkValidIntValue(value: Int, field: TemporalField): Int + open fun equals(other: InteropInterface): Boolean + override fun hashCode(): Int + open fun isFixed(): Boolean + open fun isIntValue(): Boolean + open fun isValidIntValue(value: Int): Boolean + open fun isValidValue(value: Int): Boolean + open fun largestMinimum(): Int + open fun maximum(): Int + open fun minimum(): Int + open fun smallestMaximum(): Int + override fun toString(): String + + companion object { + fun of(min: Int, max: Int): ValueRange + fun of(min: Int, maxSmallest: Int, maxLargest: Int): ValueRange + fun of(minSmallest: Int, minLargest: Int, maxSmallest: Int, maxLargest: Int): ValueRange + } +} + +external open class TemporalAmount : InteropInterface { + open fun addTo(temporal: T): T + open fun get(unit: TemporalUnit): Int + open fun subtractFrom(temporal: T): T +} + +external open class TemporalAccessor : InteropInterface { + open fun get(field: TemporalField): Int + open fun query(query: TemporalQuery): R? + open fun range(field: TemporalField): ValueRange + open fun isSupported(field: TemporalField): Boolean +} + +external open class Temporal : TemporalAccessor { + override fun isSupported(field: TemporalField): Boolean + open fun isSupported(unit: TemporalUnit): Boolean + open fun minus(amountToSubtract: Int, unit: TemporalUnit): Temporal + open fun minus(amount: TemporalAmount): Temporal + open fun plus(amountToAdd: Int, unit: TemporalUnit): Temporal + open fun plus(amount: TemporalAmount): Temporal + open fun until(endTemporal: Temporal, unit: TemporalUnit): Double + open fun with(adjuster: TemporalAdjuster): Temporal + open fun with(field: TemporalField, newValue: Int): Temporal +} + +external open class TemporalAdjuster : InteropInterface { + open fun adjustInto(temporal: Temporal): Temporal +} + +external open class TemporalQuery : InteropInterface { + open fun queryFrom(temporal: TemporalAccessor): R +} + +external open class ChronoField : TemporalField { + override fun isSupportedBy(temporal: TemporalAccessor): Boolean + override fun baseUnit(): TemporalUnit + open fun checkValidValue(value: Int): Int + open fun checkValidIntValue(value: Int): Int + override fun displayName(): String + override fun equals(other: InteropInterface): Boolean + override fun getFrom(temporal: TemporalAccessor): Int + override fun isDateBased(): Boolean + override fun isTimeBased(): Boolean + override fun name(): String + override fun range(): ValueRange + override fun rangeRefinedBy(temporal: TemporalAccessor): ValueRange + override fun rangeUnit(): TemporalUnit + override fun adjustInto(temporal: R, newValue: Int): R + override fun toString(): String + + companion object { + var ALIGNED_DAY_OF_WEEK_IN_MONTH: ChronoField + var ALIGNED_DAY_OF_WEEK_IN_YEAR: ChronoField + var ALIGNED_WEEK_OF_MONTH: ChronoField + var ALIGNED_WEEK_OF_YEAR: ChronoField + var AMPM_OF_DAY: ChronoField + var CLOCK_HOUR_OF_AMPM: ChronoField + var CLOCK_HOUR_OF_DAY: ChronoField + var DAY_OF_MONTH: ChronoField + var DAY_OF_WEEK: ChronoField + var DAY_OF_YEAR: ChronoField + var EPOCH_DAY: ChronoField + var ERA: ChronoField + var HOUR_OF_AMPM: ChronoField + var HOUR_OF_DAY: ChronoField + var INSTANT_SECONDS: ChronoField + var MICRO_OF_DAY: ChronoField + var MICRO_OF_SECOND: ChronoField + var MILLI_OF_DAY: ChronoField + var MILLI_OF_SECOND: ChronoField + var MINUTE_OF_DAY: ChronoField + var MINUTE_OF_HOUR: ChronoField + var MONTH_OF_YEAR: ChronoField + var NANO_OF_DAY: ChronoField + var NANO_OF_SECOND: ChronoField + var OFFSET_SECONDS: ChronoField + var PROLEPTIC_MONTH: ChronoField + var SECOND_OF_DAY: ChronoField + var SECOND_OF_MINUTE: ChronoField + var YEAR: ChronoField + var YEAR_OF_ERA: ChronoField + } +} + +external open class ChronoUnit : TemporalUnit { + override fun addTo(temporal: T, amount: Int): T + override fun between(temporal1: Temporal, temporal2: Temporal): Int + open fun compareTo(other: TemporalUnit): Int + override fun duration(): Duration + override fun isDateBased(): Boolean + override fun isDurationEstimated(): Boolean + override fun isSupportedBy(temporal: Temporal): Boolean + override fun isTimeBased(): Boolean + override fun toString(): String + + companion object { + var NANOS: ChronoUnit + var MICROS: ChronoUnit + var MILLIS: ChronoUnit + var SECONDS: ChronoUnit + var MINUTES: ChronoUnit + var HOURS: ChronoUnit + var HALF_DAYS: ChronoUnit + var DAYS: ChronoUnit + var WEEKS: ChronoUnit + var MONTHS: ChronoUnit + var YEARS: ChronoUnit + var DECADES: ChronoUnit + var CENTURIES: ChronoUnit + var MILLENNIA: ChronoUnit + var ERAS: ChronoUnit + var FOREVER: ChronoUnit + } +} + +external open class Clock : InteropInterface { + open fun equals(other: InteropInterface): Boolean + open fun instant(): Instant + open fun millis(): Double + open fun withZone(zone: ZoneId): Clock + open fun zone(): ZoneId + + companion object { + fun fixed(fixedInstant: Instant, zoneId: ZoneId): Clock + fun offset(baseClock: Clock, offsetDuration: Duration): Clock + fun system(zone: ZoneId): Clock + fun systemDefaultZone(): Clock + fun systemUTC(): Clock + } +} + +external open class Duration : TemporalAmount { + open fun abs(): Duration + override fun addTo(temporal: T): T + open fun compareTo(otherDuration: Duration): Int + open fun dividedBy(divisor: Int): Duration + open fun equals(other: InteropInterface): Boolean + override fun get(unit: TemporalUnit): Int + open fun isNegative(): Boolean + open fun isZero(): Boolean + open fun minus(amount: Int, unit: TemporalUnit): Duration + open fun minus(duration: Duration): Duration + open fun minusDays(daysToSubtract: Int): Duration + open fun minusHours(hoursToSubtract: Int): Duration + open fun minusMillis(millisToSubtract: Double): Duration + open fun minusMinutes(minutesToSubtract: Int): Duration + open fun minusNanos(nanosToSubtract: Double): Duration + open fun minusSeconds(secondsToSubtract: Int): Duration + open fun multipliedBy(multiplicand: Int): Duration + open fun nano(): Double + open fun negated(): Duration + open fun plus(amount: Int, unit: TemporalUnit): Duration + open fun plus(duration: Duration): Duration + open fun plusDays(daysToAdd: Int): Duration + open fun plusHours(hoursToAdd: Int): Duration + open fun plusMillis(millisToAdd: Double): Duration + open fun plusMinutes(minutesToAdd: Int): Duration + open fun plusNanos(nanosToAdd: Double): Duration + open fun plusSeconds(secondsToAdd: Int): Duration + open fun plusSecondsNanos(secondsToAdd: Int, nanosToAdd: Double): Duration + open fun seconds(): Double + override fun subtractFrom(temporal: T): T + open fun toDays(): Int + open fun toHours(): Int + open fun toJSON(): String + open fun toMillis(): Double + open fun toMinutes(): Int + open fun toNanos(): Double + override fun toString(): String + open fun withNanos(nanoOfSecond: Double): Duration + open fun withSeconds(seconds: Int): Duration + + companion object { + var ZERO: Duration + fun between(startInclusive: Temporal, endExclusive: Temporal): Duration + fun from(amount: TemporalAmount): Duration + fun of(amount: Int, unit: TemporalUnit): Duration + fun ofDays(days: Int): Duration + fun ofHours(hours: Int): Duration + fun ofMillis(millis: Double): Duration + fun ofMinutes(minutes: Int): Duration + fun ofNanos(nanos: Double): Duration + fun ofSeconds(seconds: Int, nanoAdjustment: Int): Duration + fun parse(text: String): Duration + } +} + +external open class Instant : Temporal { + open fun adjustInto(temporal: Temporal): Temporal + open fun atZone(zone: ZoneId): ZonedDateTime + open fun compareTo(otherInstant: Instant): Int + open fun epochSecond(): Double + open fun equals(other: InteropInterface): Boolean + override fun hashCode(): Int + open fun isAfter(otherInstant: Instant): Boolean + open fun isBefore(otherInstant: Instant): Boolean + override fun isSupported(fieldOrUnit: TemporalField): Boolean + override fun isSupported(fieldOrUnit: TemporalUnit): Boolean + override fun minus(amount: TemporalAmount): Instant + override fun minus(amountToSubtract: Int, unit: TemporalUnit): Instant + open fun minusMillis(millisToSubtract: Double): Instant + open fun minusNanos(nanosToSubtract: Double): Instant + open fun minusSeconds(secondsToSubtract: Int): Instant + open fun nano(): Double + override fun plus(amount: TemporalAmount): Instant + override fun plus(amountToAdd: Int, unit: TemporalUnit): Instant + open fun plusMillis(millisToAdd: Double): Instant + open fun plusNanos(nanosToAdd: Double): Instant + open fun plusSeconds(secondsToAdd: Int): Instant + open fun toEpochMilli(): Double + open fun toJSON(): String + override fun toString(): String + open fun truncatedTo(unit: TemporalUnit): Instant + override fun until(endExclusive: Temporal, unit: TemporalUnit): Double + override fun with(adjuster: TemporalAdjuster): Instant + override fun with(field: TemporalField, newValue: Int): Instant + + companion object { + var EPOCH: Instant + var MIN: Instant + var MAX: Instant + var MIN_SECONDS: Instant + var MAX_SECONDS: Instant + var FROM: TemporalQuery + fun from(temporal: TemporalAccessor): Instant + fun now(clock: Clock): Instant + fun ofEpochMilli(epochMilli: Double): Instant + fun ofEpochSecond(epochSecond: Double, nanoAdjustment: Int): Instant + fun parse(text: String): Instant + } +} + +external open class LocalDate : ChronoLocalDate { + open fun atStartOfDay(): LocalDateTime + open fun atStartOfDay(zone: ZoneId): ZonedDateTime + open fun atTime(hour: Int, minute: Int, second: Int, nanoOfSecond: Double): LocalDateTime + open fun atTime(hour: Int, minute: Int): LocalDateTime + open fun atTime(hour: Int, minute: Int, second: Int): LocalDateTime + open fun atTime(time: LocalTime): LocalDateTime + open fun chronology(): Chronology + open fun compareTo(other: LocalDate): Int + open fun dayOfMonth(): Int + open fun dayOfWeek(): DayOfWeek + open fun dayOfYear(): Int + open fun equals(other: InteropInterface): Boolean + override fun hashCode(): Int + open fun isAfter(other: LocalDate): Boolean + open fun isBefore(other: LocalDate): Boolean + open fun isEqual(other: LocalDate): Boolean + open fun isLeapYear(): Boolean + open fun isoWeekOfWeekyear(): Int + open fun isoWeekyear(): Int + override fun isSupported(fieldOrUnit: TemporalField): Boolean + override fun isSupported(fieldOrUnit: TemporalUnit): Boolean + open fun lengthOfMonth(): Int + open fun lengthOfYear(): Int + override fun minus(amount: TemporalAmount): LocalDate + override fun minus(amountToSubtract: Int, unit: TemporalUnit): LocalDate + open fun minusDays(daysToSubtract: Int): LocalDate + open fun minusMonths(monthsToSubtract: Int): LocalDate + open fun minusWeeks(weeksToSubtract: Int): LocalDate + open fun minusYears(yearsToSubtract: Int): LocalDate + open fun month(): Month + open fun monthValue(): Int + override fun plus(amount: TemporalAmount): LocalDate + override fun plus(amountToAdd: Int, unit: TemporalUnit): LocalDate + open fun plusDays(daysToAdd: Int): LocalDate + open fun plusDays(daysToAdd: Double): LocalDate + open fun plusMonths(monthsToAdd: Int): LocalDate + open fun plusMonths(monthsToAdd: Double): LocalDate + open fun plusWeeks(weeksToAdd: Int): LocalDate + open fun plusYears(yearsToAdd: Int): LocalDate + open fun toEpochDay(): Double + open fun toJSON(): String + override fun toString(): String + open fun until(endDate: TemporalAccessor): Period + override fun until(endExclusive: Temporal, unit: TemporalUnit): Double + override fun with(adjuster: TemporalAdjuster): LocalDate + override fun with(field: TemporalField, newValue: Int): LocalDate + open fun withDayOfMonth(dayOfMonth: Int): LocalDate + open fun withDayOfYear(dayOfYear: Int): LocalDate + open fun withMonth(month: Month): LocalDate + open fun withMonth(month: Int): LocalDate + open fun withYear(year: Int): LocalDate + open fun year(): Int + + companion object { + var MIN: LocalDate + var MAX: LocalDate + var EPOCH_0: LocalDate + var FROM: TemporalQuery + fun from(temporal: TemporalAccessor): LocalDate + fun now(clockOrZone: Clock): LocalDate + fun now(clockOrZone: ZoneId): LocalDate + fun of(year: Int, month: Month, dayOfMonth: Int): LocalDate + fun of(year: Int, month: Int, dayOfMonth: Int): LocalDate + fun ofEpochDay(epochDay: Int): LocalDate + fun ofInstant(instant: Instant, zoneId: ZoneId): LocalDate + fun ofYearDay(year: Int, dayOfYear: Int): LocalDate + fun parse(text: String, formatter: DateTimeFormatter): LocalDate + fun parse(text: String): LocalDate + } +} + +external open class LocalDateTime : ChronoLocalDateTime { + open fun atOffset(offset: ZoneOffset): OffsetDateTime + open fun atZone(zone: ZoneId): ZonedDateTime + open fun compareTo(other: LocalDateTime): Int + open fun dayOfMonth(): Int + open fun dayOfWeek(): DayOfWeek + open fun dayOfYear(): Int + open fun equals(other: InteropInterface): Boolean + open fun format(formatter: DateTimeFormatter): String + override fun hashCode(): Int + open fun hour(): Int + open fun isAfter(other: LocalDateTime): Boolean + open fun isBefore(other: LocalDateTime): Boolean + open fun isEqual(other: LocalDateTime): Boolean + override fun isSupported(fieldOrUnit: TemporalField): Boolean + override fun isSupported(fieldOrUnit: TemporalUnit): Boolean + override fun minus(amount: TemporalAmount): LocalDateTime + override fun minus(amountToSubtract: Int, unit: TemporalUnit): LocalDateTime + open fun minusDays(days: Int): LocalDateTime + open fun minusHours(hours: Int): LocalDateTime + open fun minusMinutes(minutes: Int): LocalDateTime + open fun minusMonths(months: Int): LocalDateTime + open fun minusNanos(nanos: Double): LocalDateTime + open fun minusSeconds(seconds: Int): LocalDateTime + open fun minusWeeks(weeks: Int): LocalDateTime + open fun minusYears(years: Int): LocalDateTime + open fun minute(): Int + open fun month(): Month + open fun monthValue(): Int + open fun nano(): Double + override fun plus(amount: TemporalAmount): LocalDateTime + override fun plus(amountToAdd: Int, unit: TemporalUnit): LocalDateTime + open fun plusDays(days: Int): LocalDateTime + open fun plusHours(hours: Int): LocalDateTime + open fun plusMinutes(minutes: Int): LocalDateTime + open fun plusMonths(months: Int): LocalDateTime + open fun plusNanos(nanos: Double): LocalDateTime + open fun plusSeconds(seconds: Int): LocalDateTime + open fun plusWeeks(weeks: Int): LocalDateTime + open fun plusYears(years: Int): LocalDateTime + open fun second(): Int + open fun toJSON(): String + open fun toLocalDate(): LocalDate + open fun toLocalTime(): LocalTime + override fun toString(): String + open fun truncatedTo(unit: TemporalUnit): LocalDateTime + override fun until(endExclusive: Temporal, unit: TemporalUnit): Double + override fun with(adjuster: TemporalAdjuster): LocalDateTime + override fun with(field: TemporalField, newValue: Int): LocalDateTime + open fun withDayOfMonth(dayOfMonth: Int): LocalDateTime + open fun withDayOfYear(dayOfYear: Int): LocalDateTime + open fun withHour(hour: Int): LocalDateTime + open fun withMinute(minute: Int): LocalDateTime + open fun withMonth(month: Int): LocalDateTime + open fun withMonth(month: Month): LocalDateTime + open fun withNano(nanoOfSecond: Int): LocalDateTime + open fun withSecond(second: Int): LocalDateTime + open fun withYear(year: Int): LocalDateTime + open fun year(): Int + + companion object { + var MIN: LocalDateTime + var MAX: LocalDateTime + var FROM: TemporalQuery + fun from(temporal: TemporalAccessor): LocalDateTime + fun now(clockOrZone: Clock): LocalDateTime + fun now(clockOrZone: ZoneId): LocalDateTime + fun of(date: LocalDate, time: LocalTime): LocalDateTime + fun of(year: Int, month: Month, dayOfMonth: Int, hour: Int, minute: Int, second: Int, nanoSecond: Int): LocalDateTime + fun of(year: Int, month: Int, dayOfMonth: Int, hour: Int, minute: Int, second: Int, nanoSecond: Int): LocalDateTime + fun ofEpochSecond(epochSecond: Double, nanoOfSecond: Int, offset: ZoneOffset): LocalDateTime + fun ofEpochSecond(epochSecond: Double, offset: ZoneOffset): LocalDateTime + fun ofInstant(instant: Instant, zoneId: ZoneId): LocalDateTime + fun parse(text: String): LocalDateTime + } +} + +external open class LocalTime : Temporal { + open fun adjustInto(temporal: Temporal): Temporal + open fun atDate(date: LocalDate): LocalDateTime + open fun compareTo(other: LocalTime): Int + open fun equals(other: InteropInterface): Boolean + open fun format(formatter: DateTimeFormatter): String + override fun hashCode(): Int + open fun hour(): Int + open fun isAfter(other: LocalTime): Boolean + open fun isBefore(other: LocalTime): Boolean + override fun isSupported(fieldOrUnit: TemporalField): Boolean + override fun isSupported(fieldOrUnit: TemporalUnit): Boolean + override fun minus(amount: TemporalAmount): LocalTime + override fun minus(amountToSubtract: Int, unit: TemporalUnit): LocalTime + open fun minusHours(hoursToSubtract: Int): LocalTime + open fun minusMinutes(minutesToSubtract: Int): LocalTime + open fun minusNanos(nanosToSubtract: Double): LocalTime + open fun minusSeconds(secondsToSubtract: Int): LocalTime + open fun minute(): Int + open fun nano(): Double + override fun plus(amount: TemporalAmount): LocalTime + override fun plus(amountToAdd: Int, unit: TemporalUnit): LocalTime + open fun plusHours(hoursToAdd: Int): LocalTime + open fun plusMinutes(minutesToAdd: Int): LocalTime + open fun plusNanos(nanosToAdd: Double): LocalTime + open fun plusSeconds(secondstoAdd: Int): LocalTime + open fun second(): Int + open fun toJSON(): String + open fun toNanoOfDay(): Double + open fun toSecondOfDay(): Int + override fun toString(): String + open fun truncatedTo(unit: ChronoUnit): LocalTime + override fun until(endExclusive: Temporal, unit: TemporalUnit): Double + override fun with(adjuster: TemporalAdjuster): LocalTime + override fun with(field: TemporalField, newValue: Int): LocalTime + open fun withHour(hour: Int): LocalTime + open fun withMinute(minute: Int): LocalTime + open fun withNano(nanoOfSecond: Int): LocalTime + open fun withSecond(second: Int): LocalTime + + companion object { + var MIN: LocalTime + var MAX: LocalTime + var MIDNIGHT: LocalTime + var NOON: LocalTime + var HOURS_PER_DAY: Int + var MINUTES_PER_HOUR: Int + var MINUTES_PER_DAY: Int + var SECONDS_PER_MINUTE: Int + var SECONDS_PER_HOUR: Int + var SECONDS_PER_DAY: Int + var MILLIS_PER_DAY: Double + var MICROS_PER_DAY: Double + var NANOS_PER_SECOND: Double + var NANOS_PER_MINUTE: Double + var NANOS_PER_HOUR: Double + var NANOS_PER_DAY: Double + var FROM: TemporalQuery + fun from(temporal: TemporalAccessor): LocalTime + fun now(clockOrZone: Clock): LocalTime + fun now(clockOrZone: ZoneId): LocalTime + fun of(hour: Int, minute: Int, second: Int, nanoOfSecond: Int): LocalTime + fun ofInstant(instant: Instant, zone: ZoneId): LocalTime + fun ofNanoOfDay(nanoOfDay: Double): LocalTime + fun ofSecondOfDay(secondOfDay: Int, nanoOfSecond: Int): LocalTime + fun parse(text: String): LocalTime + } +} + +external open class MonthDay : TemporalAccessor { + open fun adjustInto(temporal: Temporal): Temporal + open fun atYear(year: Int): LocalDate + open fun compareTo(other: MonthDay): Int + open fun dayOfMonth(): Int + open fun equals(other: InteropInterface): Boolean + open fun format(formatter: DateTimeFormatter): String + open fun isAfter(other: MonthDay): Boolean + open fun isBefore(other: MonthDay): Boolean + override fun isSupported(field: TemporalField): Boolean + open fun isValidYear(year: Int): Boolean + open fun month(): Month + open fun monthValue(): Int + open fun toJSON(): String + override fun toString(): String + open fun with(month: Month): MonthDay + open fun withDayOfMonth(dayOfMonth: Int): MonthDay + open fun withMonth(month: Int): MonthDay + + companion object { + var FROM: TemporalQuery + fun from(temporal: TemporalAccessor): MonthDay + fun now(zoneIdOrClock: ZoneId): MonthDay + fun now(zoneIdOrClock: Clock): MonthDay + fun of(month: Month, dayOfMonth: Int): MonthDay + fun of(month: Int, dayOfMonth: Int): MonthDay + fun parse(text: String, formatter: DateTimeFormatter): MonthDay + } +} + +external open class Period : TemporalAmount { + override fun addTo(temporal: T): T + open fun chronology(): IsoChronology + open fun days(): Int + open fun equals(other: InteropInterface): Boolean + override fun get(unit: TemporalUnit): Int + override fun hashCode(): Int + open fun isNegative(): Boolean + open fun isZero(): Boolean + open fun minus(amountToSubtract: TemporalAmount): Period + open fun minusDays(daysToSubtract: Int): Period + open fun minusMonths(monthsToSubtract: Int): Period + open fun minusYears(yearsToSubtract: Int): Period + open fun months(): Int + open fun multipliedBy(scalar: Int): Period + open fun negated(): Period + open fun normalized(): Period + open fun plus(amountToAdd: TemporalAmount): Period + open fun plusDays(daysToAdd: Int): Period + open fun plusMonths(monthsToAdd: Int): Period + open fun plusYears(yearsToAdd: Int): Period + override fun subtractFrom(temporal: T): T + open fun toJSON(): String + override fun toString(): String + open fun toTotalMonths(): Int + open fun withDays(days: Int): Period + open fun withMonths(months: Int): Period + open fun withYears(years: Int): Period + open fun years(): Int + + companion object { + var ZERO: Period + fun between(startDate: LocalDate, endDate: LocalDate): Period + fun from(amount: TemporalAmount): Period + fun of(years: Int, months: Int, days: Int): Period + fun ofDays(days: Int): Period + fun ofMonths(months: Int): Period + fun ofWeeks(weeks: Int): Period + fun ofYears(years: Int): Period + fun parse(text: String): Period + } +} + +external open class Year : Temporal { + open fun adjustInto(temporal: Temporal): Temporal + open fun atDay(dayOfYear: Int): LocalDate + open fun atMonth(month: Month): YearMonth + open fun atMonth(month: Int): YearMonth + open fun atMonthDay(monthDay: MonthDay): LocalDate + open fun compareTo(other: Year): Int + open fun equals(other: InteropInterface): Boolean + open fun isAfter(other: Year): Boolean + open fun isBefore(other: Year): Boolean + open fun isLeap(): Boolean + override fun isSupported(fieldOrUnit: TemporalField): Boolean + override fun isSupported(fieldOrUnit: TemporalUnit): Boolean + open fun isValidMonthDay(monthDay: MonthDay): Boolean + open fun length(): Int + override fun minus(amount: TemporalAmount): Year + override fun minus(amountToSubtract: Int, unit: TemporalUnit): Year + open fun minusYears(yearsToSubtract: Int): Year + override fun plus(amount: TemporalAmount): Year + override fun plus(amountToAdd: Int, unit: TemporalUnit): Year + open fun plusYears(yearsToAdd: Int): Year + open fun toJSON(): String + override fun toString(): String + override fun until(endExclusive: Temporal, unit: TemporalUnit): Double + open fun value(): Int + override fun with(adjuster: TemporalAdjuster): Year + override fun with(field: TemporalField, newValue: Int): Year + + companion object { + var MIN_VALUE: Int + var MAX_VALUE: Int + var FROM: TemporalQuery + fun from(temporal: TemporalAccessor): Year + fun isLeap(year: Int): Boolean + fun now(zoneIdOrClock: ZoneId): Year + fun now(zoneIdOrClock: Clock): Year + fun of(isoYear: Int): Year + fun parse(text: String, formatter: DateTimeFormatter): Year + } +} + +external open class YearMonth : Temporal { + open fun adjustInto(temporal: Temporal): Temporal + open fun atDay(dayOfMonth: Int): LocalDate + open fun atEndOfMonth(): LocalDate + open fun compareTo(other: YearMonth): Int + open fun equals(other: InteropInterface): Boolean + open fun format(formatter: DateTimeFormatter): String + open fun isAfter(other: YearMonth): Boolean + open fun isBefore(other: YearMonth): Boolean + open fun isLeapYear(): Boolean + override fun isSupported(fieldOrUnit: TemporalField): Boolean + override fun isSupported(fieldOrUnit: TemporalUnit): Boolean + open fun isValidDay(): Boolean + open fun lengthOfMonth(): Int + open fun lengthOfYear(): Int + override fun minus(amount: TemporalAmount): YearMonth + override fun minus(amountToSubtract: Int, unit: TemporalUnit): YearMonth + open fun minusMonths(monthsToSubtract: Int): YearMonth + open fun minusYears(yearsToSubtract: Int): YearMonth + open fun month(): Month + open fun monthValue(): Int + override fun plus(amount: TemporalAmount): YearMonth + override fun plus(amountToAdd: Int, unit: TemporalUnit): YearMonth + open fun plusMonths(monthsToAdd: Int): YearMonth + open fun plusYears(yearsToAdd: Int): YearMonth + open fun toJSON(): String + override fun until(endExclusive: Temporal, unit: TemporalUnit): Double + override fun with(adjuster: TemporalAdjuster): YearMonth + override fun with(field: TemporalField, newValue: Int): YearMonth + open fun withMonth(month: Int): YearMonth + open fun withYear(year: Int): YearMonth + open fun year(): Int + + companion object { + var FROM: TemporalQuery + fun from(temporal: TemporalAccessor): YearMonth + fun now(zoneIdOrClock: ZoneId): YearMonth + fun now(zoneIdOrClock: Clock): YearMonth + fun of(year: Int, monthOrInt: Month): YearMonth + fun of(year: Int, monthOrInt: Int): YearMonth + fun parse(text: String, formatter: DateTimeFormatter): YearMonth + } +} + +external open class OffsetDateTime : Temporal { + open fun adjustInto(temporal: Temporal): Temporal + open fun atZoneSameInstant(zone: ZoneId): ZonedDateTime + open fun atZoneSimilarLocal(zone: ZoneId): ZonedDateTime + open fun compareTo(other: OffsetDateTime): Int + open fun equals(obj: InteropInterface): Boolean + open fun format(formatter: DateTimeFormatter): String + override fun get(field: TemporalField): Int + open fun dayOfMonth(): Int + open fun dayOfWeek(): DayOfWeek + open fun dayOfYear(): Int + open fun hour(): Int + open fun minute(): Int + open fun month(): Month + open fun monthValue(): Int + open fun nano(): Double + open fun offset(): ZoneOffset + open fun second(): Int + open fun year(): Int + override fun hashCode(): Int + open fun isAfter(other: OffsetDateTime): Boolean + open fun isBefore(other: OffsetDateTime): Boolean + open fun isEqual(other: OffsetDateTime): Boolean + override fun isSupported(fieldOrUnit: TemporalField): Boolean + override fun isSupported(fieldOrUnit: TemporalUnit): Boolean + override fun minus(amountToSubtract: Int, unit: TemporalUnit): OffsetDateTime + override fun minus(amountToSubtract: TemporalAmount): OffsetDateTime + open fun minusDays(days: Int): OffsetDateTime + open fun minusHours(hours: Int): OffsetDateTime + open fun minusMinutes(minutes: Int): OffsetDateTime + open fun minusMonths(months: Int): OffsetDateTime + open fun minusNanos(nanos: Double): OffsetDateTime + open fun minusSeconds(seconds: Int): OffsetDateTime + open fun minusWeeks(weeks: Int): OffsetDateTime + open fun minusYears(years: Int): OffsetDateTime + override fun plus(amountToAdd: Int, unit: TemporalUnit): OffsetDateTime + override fun plus(amountToAdd: TemporalAmount): OffsetDateTime + open fun plusDays(days: Int): OffsetDateTime + open fun plusHours(hours: Int): OffsetDateTime + open fun plusMinutes(minutes: Int): OffsetDateTime + open fun plusMonths(months: Int): OffsetDateTime + open fun plusNanos(nanos: Double): OffsetDateTime + open fun plusSeconds(seconds: Int): OffsetDateTime + open fun plusWeeks(weeks: Int): OffsetDateTime + open fun plusYears(years: Int): OffsetDateTime + override fun query(query: TemporalQuery): R? + override fun range(field: TemporalField): ValueRange + open fun toEpochSecond(): Double + open fun toJSON(): String + open fun toInstant(): Instant + open fun toLocalDate(): LocalDate + open fun toLocalDateTime(): LocalDateTime + open fun toLocalTime(): LocalTime + open fun toOffsetTime(): OffsetTime + override fun toString(): String + open fun truncatedTo(unit: TemporalUnit): OffsetDateTime + override fun until(endExclusive: Temporal, unit: TemporalUnit): Double + override fun with(adjuster: TemporalAdjuster): OffsetDateTime + override fun with(field: TemporalField, newValue: Int): OffsetDateTime + open fun withDayOfMonth(dayOfMonth: Int): OffsetDateTime + open fun withDayOfYear(dayOfYear: Int): OffsetDateTime + open fun withHour(hour: Int): OffsetDateTime + open fun withMinute(minute: Int): OffsetDateTime + open fun withMonth(month: Int): OffsetDateTime + open fun withNano(nanoOfSecond: Int): OffsetDateTime + open fun withOffsetSameInstant(offset: ZoneOffset): OffsetDateTime + open fun withOffsetSameLocal(offset: ZoneOffset): OffsetDateTime + open fun withSecond(second: Int): OffsetDateTime + open fun withYear(year: Int): OffsetDateTime + + companion object { + var MIN: OffsetDateTime + var MAX: OffsetDateTime + var FROM: TemporalQuery + fun from(temporal: TemporalAccessor): OffsetDateTime + fun now(clockOrZone: Clock): OffsetDateTime + fun now(clockOrZone: ZoneId): OffsetDateTime + fun of(dateTime: LocalDateTime, offset: ZoneOffset): OffsetDateTime + fun of(date: LocalDate, time: LocalTime, offset: ZoneOffset): OffsetDateTime + fun of(year: Int, month: Int, day: Int, hour: Int, minute: Int, second: Int, nanoOfSecond: Int, offset: ZoneOffset): OffsetDateTime + fun ofInstant(instant: Instant, zone: ZoneId): OffsetDateTime + fun parse(text: String): OffsetDateTime + } +} + +external open class OffsetTime : Temporal { + open fun adjustInto(temporal: Temporal): Temporal + open fun atDate(date: LocalDate): OffsetDateTime + open fun compareTo(other: OffsetTime): Int + open fun equals(other: InteropInterface): Boolean + open fun format(formatter: DateTimeFormatter): String + override fun get(field: TemporalField): Int + open fun hour(): Int + open fun minute(): Int + open fun nano(): Double + open fun offset(): ZoneOffset + open fun second(): Int + override fun hashCode(): Int + open fun isAfter(other: OffsetTime): Boolean + open fun isBefore(other: OffsetTime): Boolean + open fun isEqual(other: OffsetTime): Boolean + override fun isSupported(fieldOrUnit: TemporalField): Boolean + override fun isSupported(fieldOrUnit: TemporalUnit): Boolean + override fun minus(amountToSubtract: Int, unit: TemporalUnit): OffsetTime + override fun minus(amountToSubtract: TemporalAmount): OffsetTime + open fun minusHours(hours: Int): OffsetTime + open fun minusMinutes(minutes: Int): OffsetTime + open fun minusNanos(nanos: Double): OffsetTime + open fun minusSeconds(seconds: Int): OffsetTime + override fun plus(amountToAdd: Int, unit: TemporalUnit): OffsetTime + override fun plus(amountToAdd: TemporalAmount): OffsetTime + open fun plusHours(hours: Int): OffsetTime + open fun plusMinutes(minutes: Int): OffsetTime + open fun plusNanos(nanos: Double): OffsetTime + open fun plusSeconds(seconds: Int): OffsetTime + override fun query(query: TemporalQuery): R? + override fun range(field: TemporalField): ValueRange + open fun toEpochSecond(date: LocalDate): Double + open fun toJSON(): String + open fun toLocalTime(): LocalTime + override fun toString(): String + open fun truncatedTo(unit: TemporalUnit): OffsetTime + override fun until(endExclusive: Temporal, unit: TemporalUnit): Double + override fun with(adjuster: TemporalAdjuster): OffsetTime + override fun with(field: TemporalField, newValue: Int): OffsetTime + open fun withHour(hour: Int): OffsetTime + open fun withMinute(minute: Int): OffsetTime + open fun withNano(nanoOfSecond: Int): OffsetTime + open fun withOffsetSameInstant(offset: ZoneOffset): OffsetTime + open fun withOffsetSameLocal(offset: ZoneOffset): OffsetTime + open fun withSecond(second: Int): OffsetTime + + companion object { + var MIN: OffsetTime + var MAX: OffsetTime + var FROM: TemporalQuery + fun from(temporal: TemporalAccessor): OffsetTime + fun now(clockOrZone: Clock): OffsetTime + fun now(clockOrZone: ZoneId): OffsetTime + fun of(time: LocalTime, offset: ZoneOffset): OffsetTime + fun of(hour: Int, minute: Int, second: Int, nanoOfSecond: Int, offset: ZoneOffset): OffsetTime + fun ofInstant(instant: Instant, zone: ZoneId): OffsetTime + fun parse(text: String, formatter: DateTimeFormatter): OffsetTime + } +} + +external open class ZonedDateTime : ChronoZonedDateTime { + open fun dayOfMonth(): Int + open fun dayOfWeek(): DayOfWeek + open fun dayOfYear(): Int + override fun equals(other: InteropInterface): Boolean + override fun format(formatter: DateTimeFormatter): String + override fun hashCode(): Int + open fun hour(): Int + override fun isSupported(fieldOrUnit: TemporalField): Boolean + override fun isSupported(fieldOrUnit: TemporalUnit): Boolean + override fun minus(amount: TemporalAmount): ZonedDateTime + override fun minus(amountToSubtract: Int, unit: TemporalUnit): ZonedDateTime + open fun minusDays(days: Int): ZonedDateTime + open fun minusHours(hours: Int): ZonedDateTime + open fun minusMinutes(minutes: Int): ZonedDateTime + open fun minusMonths(months: Int): ZonedDateTime + open fun minusNanos(nanos: Double): ZonedDateTime + open fun minusSeconds(seconds: Int): ZonedDateTime + open fun minusWeeks(weeks: Int): ZonedDateTime + open fun minusYears(years: Int): ZonedDateTime + open fun minute(): Int + open fun month(): Month + open fun monthValue(): Int + open fun nano(): Double + open fun offset(): ZoneOffset + override fun plus(amount: TemporalAmount): ZonedDateTime + override fun plus(amountToAdd: Int, unit: TemporalUnit): ZonedDateTime + open fun plusDays(days: Int): ZonedDateTime + open fun plusDays(days: Double): ZonedDateTime + open fun plusHours(hours: Int): ZonedDateTime + open fun plusMinutes(minutes: Int): ZonedDateTime + open fun plusMonths(months: Int): ZonedDateTime + open fun plusMonths(months: Double): ZonedDateTime + open fun plusNanos(nanos: Double): ZonedDateTime + open fun plusSeconds(seconds: Int): ZonedDateTime + open fun plusWeeks(weeks: Int): ZonedDateTime + open fun plusYears(years: Int): ZonedDateTime + override fun range(field: TemporalField): ValueRange + open fun second(): Int + open fun toJSON(): String + open fun toLocalDate(): LocalDate + open fun toLocalDateTime(): LocalDateTime + open fun toLocalTime(): LocalTime + open fun toOffsetDateTime(): OffsetDateTime + override fun toString(): String + open fun truncatedTo(unit: TemporalUnit): ZonedDateTime + override fun until(endExclusive: Temporal, unit: TemporalUnit): Double + override fun with(adjuster: TemporalAdjuster): ZonedDateTime + override fun with(field: TemporalField, newValue: Int): ZonedDateTime + open fun withDayOfMonth(dayOfMonth: Int): ZonedDateTime + open fun withDayOfYear(dayOfYear: Int): ZonedDateTime + open fun withEarlierOffsetAtOverlap(): ZonedDateTime + open fun withFixedOffsetZone(): ZonedDateTime + open fun withHour(hour: Int): ZonedDateTime + open fun withLaterOffsetAtOverlap(): ZonedDateTime + open fun withMinute(minute: Int): ZonedDateTime + open fun withMonth(month: Int): ZonedDateTime + open fun withNano(nanoOfSecond: Int): ZonedDateTime + open fun withSecond(second: Int): ZonedDateTime + open fun withYear(year: Int): ZonedDateTime + open fun withZoneSameInstant(zone: ZoneId): ZonedDateTime + open fun withZoneSameLocal(zone: ZoneId): ZonedDateTime + open fun year(): Int + open fun zone(): ZoneId + + companion object { + var FROM: TemporalQuery + fun from(temporal: TemporalAccessor): ZonedDateTime + fun now(clockOrZone: Clock): ZonedDateTime + fun now(clockOrZone: ZoneId): ZonedDateTime + fun of(localDateTime: LocalDateTime, zone: ZoneId): ZonedDateTime + fun of(date: LocalDate, time: LocalTime, zone: ZoneId): ZonedDateTime + fun of(year: Int, month: Int, dayOfMonth: Int, hour: Int, minute: Int, second: Int, nanoOfSecond: Int, zone: ZoneId): ZonedDateTime + fun ofInstant(instant: Instant, zone: ZoneId): ZonedDateTime + fun ofInstant(localDateTime: LocalDateTime, offset: ZoneOffset, zone: ZoneId): ZonedDateTime + fun ofLocal(localDateTime: LocalDateTime, zone: ZoneId, preferredOffset: ZoneOffset?): ZonedDateTime + fun ofStrict(localDateTime: LocalDateTime, offset: ZoneOffset, zone: ZoneId): ZonedDateTime + fun parse(text: String): ZonedDateTime + } +} + +external open class ZoneId : InteropInterface { + open fun equals(other: InteropInterface): Boolean + override fun hashCode(): Int + open fun id(): String + open fun normalized(): ZoneId + open fun rules(): ZoneRules + open fun toJSON(): String + override fun toString(): String + + companion object { + var SYSTEM: ZoneId + var UTC: ZoneId + fun systemDefault(): ZoneId + fun of(zoneId: String): ZoneId + fun ofOffset(prefix: String, offset: ZoneOffset): ZoneId + fun from(temporal: TemporalAccessor): ZoneId + fun getAvailableZoneIds(): InteropInterface + } +} + +external open class ZoneOffset : ZoneId { + open fun adjustInto(temporal: Temporal): Temporal + open fun compareTo(other: ZoneOffset): Int + override fun equals(other: InteropInterface): Boolean + open fun get(field: TemporalField): Int + override fun hashCode(): Int + override fun id(): String + override fun rules(): ZoneRules + override fun toString(): String + open fun totalSeconds(): Int + + companion object { + var MAX_SECONDS: ZoneOffset + var UTC: ZoneOffset + var MIN: ZoneOffset + var MAX: ZoneOffset + fun of(offsetId: String): ZoneOffset + fun ofHours(hours: Int): ZoneOffset + fun ofHoursMinutes(hours: Int, minutes: Int): ZoneOffset + fun ofHoursMinutesSeconds(hours: Int, minutes: Int, seconds: Int): ZoneOffset + fun ofTotalMinutes(totalMinutes: Int): ZoneOffset + fun ofTotalSeconds(totalSeconds: Int): ZoneOffset + } +} + +external open class ZoneRegion : ZoneId { + override fun id(): String + override fun rules(): ZoneRules + + companion object { + fun ofId(zoneId: String): ZoneId + } +} + +external open class DayOfWeek : TemporalAccessor { + open fun adjustInto(temporal: Temporal): Temporal + open fun compareTo(other: DayOfWeek): Int + open fun equals(other: InteropInterface): Boolean + open fun displayName(style: TextStyle, locale: Locale): String + override fun isSupported(field: TemporalField): Boolean + open fun minus(days: Int): DayOfWeek + open fun name(): String + open fun ordinal(): Int + open fun plus(days: Int): DayOfWeek + open fun toJSON(): String + override fun toString(): String + open fun value(): Int + + companion object { + var MONDAY: DayOfWeek + var TUESDAY: DayOfWeek + var WEDNESDAY: DayOfWeek + var THURSDAY: DayOfWeek + var FRIDAY: DayOfWeek + var SATURDAY: DayOfWeek + var SUNDAY: DayOfWeek + var FROM: TemporalQuery + fun from(temporal: TemporalAccessor): DayOfWeek + fun of(dayOfWeek: Int): DayOfWeek + fun valueOf(name: String): DayOfWeek + } +} + +external open class Month : TemporalAccessor { + open fun adjustInto(temporal: Temporal): Temporal + open fun compareTo(other: Month): Int + open fun equals(other: InteropInterface): Boolean + open fun firstDayOfYear(leapYear: Boolean): Int + open fun firstMonthOfQuarter(): Month + open fun displayName(style: TextStyle, locale: Locale): String + override fun isSupported(field: TemporalField): Boolean + open fun length(leapYear: Boolean): Int + open fun maxLength(): Int + open fun minLength(): Int + open fun minus(months: Int): Month + open fun name(): String + open fun ordinal(): Int + open fun plus(months: Int): Month + open fun toJSON(): String + override fun toString(): String + open fun value(): Int + + companion object { + var JANUARY: Month + var FEBRUARY: Month + var MARCH: Month + var APRIL: Month + var MAY: Month + var JUNE: Month + var JULY: Month + var AUGUST: Month + var SEPTEMBER: Month + var OCTOBER: Month + var NOVEMBER: Month + var DECEMBER: Month + fun from(temporal: TemporalAccessor): Month + fun of(month: Int): Month + fun valueOf(name: String): Month + } +} + +external open class DateTimeFormatter : InteropInterface { + open fun chronology(): Chronology? + open fun decimalStyle(): DecimalStyle + open fun format(temporal: TemporalAccessor): String + open fun locale(): InteropInterface + open fun parse(text: String): TemporalAccessor + open fun parse(text: String, query: TemporalQuery): T + open fun parseUnresolved(text: String, position: ParsePosition): TemporalAccessor + override fun toString(): String + open fun withChronology(chrono: Chronology): DateTimeFormatter + open fun withLocale(locale: Locale): DateTimeFormatter + open fun withResolverStyle(resolverStyle: ResolverStyle): DateTimeFormatter + + companion object { + var ISO_LOCAL_DATE: DateTimeFormatter + var ISO_LOCAL_TIME: DateTimeFormatter + var ISO_LOCAL_DATE_TIME: DateTimeFormatter + var ISO_INSTANT: DateTimeFormatter + var ISO_OFFSET_DATE_TIME: DateTimeFormatter + var ISO_ZONED_DATE_TIME: DateTimeFormatter + fun ofPattern(pattern: String): DateTimeFormatter + fun parsedExcessDays(): TemporalQuery + } +} + +external open class DateTimeFormatterBuilder : InteropInterface { + open fun append(formatter: DateTimeFormatter): DateTimeFormatterBuilder + open fun appendFraction(field: TemporalField, minWidth: Int, maxWidth: Int, decimalPoint: Boolean): DateTimeFormatterBuilder + open fun appendInstant(fractionalDigits: Int): DateTimeFormatterBuilder + open fun appendLiteral(literal: InteropInterface): DateTimeFormatterBuilder + open fun appendOffset(pattern: String, noOffsetText: String): DateTimeFormatterBuilder + open fun appendOffsetId(): DateTimeFormatterBuilder + open fun appendPattern(pattern: String): DateTimeFormatterBuilder + open fun appendValue(field: TemporalField, width: Int, maxWidth: Int, signStyle: SignStyle): DateTimeFormatterBuilder + open fun appendValueReduced(field: TemporalField, width: Int, maxWidth: Int, base: ChronoLocalDate): DateTimeFormatterBuilder + open fun appendValueReduced(field: TemporalField, width: Int, maxWidth: Int, base: Int): DateTimeFormatterBuilder + open fun appendZoneId(): DateTimeFormatterBuilder + open fun optionalEnd(): DateTimeFormatterBuilder + open fun optionalStart(): DateTimeFormatterBuilder + open fun padNext(): DateTimeFormatterBuilder + open fun parseCaseInsensitive(): DateTimeFormatterBuilder + open fun parseCaseSensitive(): DateTimeFormatterBuilder + open fun parseLenient(): DateTimeFormatterBuilder + open fun parseStrict(): DateTimeFormatterBuilder + open fun toFormatter(resolverStyle: ResolverStyle): DateTimeFormatter +} + +external open class DecimalStyle : InteropInterface { + open fun decimalSeparator(): String + open fun equals(other: InteropInterface): Boolean + override fun hashCode(): InteropInterface + open fun negativeSign(): String + open fun positiveSign(): String + override fun toString(): String + open fun zeroDigit(): String +} + +external open class ResolverStyle : InteropInterface { + open fun equals(other: InteropInterface): Boolean + open fun toJSON(): String + override fun toString(): String + + companion object { + var STRICT: ResolverStyle + var SMART: ResolverStyle + var LENIENT: ResolverStyle + } +} + +external open class SignStyle : InteropInterface { + open fun equals(other: InteropInterface): Boolean + open fun toJSON(): String + override fun toString(): String + + companion object { + var NORMAL: SignStyle + var NEVER: SignStyle + var ALWAYS: SignStyle + var EXCEEDS_PAD: SignStyle + var NOT_NEGATIVE: SignStyle + } +} + +external open class TextStyle : InteropInterface { + open fun asNormal(): TextStyle + open fun asStandalone(): TextStyle + open fun isStandalone(): Boolean + open fun equals(other: InteropInterface): Boolean + open fun toJSON(): String + override fun toString(): String + + companion object { + var FULL: TextStyle + var FULL_STANDALONE: TextStyle + var SHORT: TextStyle + var SHORT_STANDALONE: TextStyle + var NARROW: TextStyle + var NARROW_STANDALONE: TextStyle + } +} + +external open class ParsePosition(index: Int) : InteropInterface { + open fun getIndex(): Int + open fun setIndex(index: Int) + open fun getErrorIndex(): Int + open fun setErrorIndex(errorIndex: Int) +} + +external open class ZoneOffsetTransition : InteropInterface { + open fun compareTo(transition: ZoneOffsetTransition): Int + open fun dateTimeAfter(): LocalDateTime + open fun dateTimeBefore(): LocalDateTime + open fun duration(): Duration + open fun durationSeconds(): Int + open fun equals(other: InteropInterface): Boolean + override fun hashCode(): Int + open fun instant(): Instant + open fun isGap(): Boolean + open fun isOverlap(): Boolean + open fun isValidOffset(offset: ZoneOffset): Boolean + open fun offsetAfter(): ZoneOffset + open fun offsetBefore(): ZoneOffset + open fun toEpochSecond(): Double + override fun toString(): String + + companion object { + fun of(transition: LocalDateTime, offsetBefore: ZoneOffset, offsetAfter: ZoneOffset): ZoneOffsetTransition + } +} + +external interface ZoneOffsetTransitionRule : InteropInterface + +external open class ZoneRules : InteropInterface { + open fun offset(instant: Instant): ZoneOffset + open fun offset(localDateTime: LocalDateTime): ZoneOffset + open fun toJSON(): String + open fun daylightSavings(instant: Instant): Duration + open fun isDaylightSavings(instant: Instant): Boolean + open fun isFixedOffset(): Boolean + open fun isValidOffset(localDateTime: LocalDateTime, offset: ZoneOffset): Boolean + open fun nextTransition(instant: Instant): ZoneOffsetTransition + open fun offsetOfEpochMilli(epochMilli: Double): ZoneOffset + open fun offsetOfInstant(instant: Instant): ZoneOffset + open fun offsetOfLocalDateTime(localDateTime: LocalDateTime): ZoneOffset + open fun previousTransition(instant: Instant): ZoneOffsetTransition + open fun standardOffset(instant: Instant): ZoneOffset + override fun toString(): String + open fun transition(localDateTime: LocalDateTime): ZoneOffsetTransition + + companion object { + fun of(offest: ZoneOffset): ZoneRules + } +} + +external open class ZoneRulesProvider : InteropInterface { + companion object { + fun getRules(zoneId: String): ZoneRules + } +} + +external open class IsoChronology : InteropInterface { + open fun equals(other: InteropInterface): Boolean + open fun resolveDate(fieldValues: InteropInterface, resolverStyle: InteropInterface): InteropInterface + override fun toString(): String + + companion object { + fun isLeapYear(prolepticYear: Int): Boolean + } +} + +external open class ChronoLocalDate : Temporal { + open fun adjustInto(temporal: Temporal): Temporal + open fun format(formatter: DateTimeFormatter): String + override fun isSupported(fieldOrUnit: TemporalField): Boolean + override fun isSupported(fieldOrUnit: TemporalUnit): Boolean +} + +external open class ChronoLocalDateTime : Temporal { + open fun adjustInto(temporal: Temporal): Temporal + open fun chronology(): Chronology + open fun toEpochSecond(offset: ZoneOffset): Double + open fun toInstant(offset: ZoneOffset): Instant +} + +external open class ChronoZonedDateTime : Temporal { + open fun compareTo(other: ChronoZonedDateTime): Int + open fun equals(other: InteropInterface): Boolean + open fun format(formatter: DateTimeFormatter): String + open fun isAfter(other: ChronoZonedDateTime): Boolean + open fun isBefore(other: ChronoZonedDateTime): Boolean + open fun isEqual(other: ChronoZonedDateTime): Boolean + open fun toEpochSecond(): Double + open fun toInstant(): Instant +} + +external interface Locale : InteropInterface + +external fun use(plugin: () -> InteropInterface): InteropInterface \ No newline at end of file diff --git a/core/js/src/JSJodaExceptions.kt b/core/js/src/JSJodaExceptions.kt index 5e70f3d4..9d0b5347 100644 --- a/core/js/src/JSJodaExceptions.kt +++ b/core/js/src/JSJodaExceptions.kt @@ -5,6 +5,7 @@ package kotlinx.datetime -internal fun Throwable.isJodaArithmeticException(): Boolean = this.asDynamic().name == "ArithmeticException" -internal fun Throwable.isJodaDateTimeException(): Boolean = this.asDynamic().name == "DateTimeException" -internal fun Throwable.isJodaDateTimeParseException(): Boolean = this.asDynamic().name == "DateTimeParseException" +internal actual fun Throwable.hasJsExceptionName(name: String): Boolean = + this.asDynamic().name == name + +internal actual inline fun jsTry(crossinline body: () -> T): T = body() \ No newline at end of file diff --git a/core/js/src/PlatformSpecifics.kt b/core/js/src/PlatformSpecifics.kt new file mode 100644 index 00000000..bfa166f1 --- /dev/null +++ b/core/js/src/PlatformSpecifics.kt @@ -0,0 +1,16 @@ +/* + * Copyright 2019-2023 JetBrains s.r.o. and contributors. + * Use of this source code is governed by the Apache 2.0 License that can be found in the LICENSE.txt file. + */ +package kotlinx.datetime.internal + +import kotlinx.datetime.internal.JSJoda.ZoneId + +internal actual fun getAvailableZoneIdsSet(): Set = + ZoneId.getAvailableZoneIds().unsafeCast>().toSet() + +public actual external interface InteropInterface + +public actual typealias JsNonModule = kotlin.js.JsNonModule + +public actual typealias JsModule = kotlin.js.JsModule \ No newline at end of file diff --git a/core/js/src/kotlinx.datetime.internal.JSJoda.module_@js-joda_core._aliases.kt b/core/js/src/kotlinx.datetime.internal.JSJoda.module_@js-joda_core._aliases.kt deleted file mode 100644 index b4d1f142..00000000 --- a/core/js/src/kotlinx.datetime.internal.JSJoda.module_@js-joda_core._aliases.kt +++ /dev/null @@ -1,23 +0,0 @@ -@file:Suppress("NO_EXPLICIT_VISIBILITY_IN_API_MODE", "INTERFACE_WITH_SUPERCLASS", "OVERRIDING_FINAL_MEMBER", "RETURN_TYPE_MISMATCH_ON_OVERRIDE", "CONFLICTING_OVERLOADS", "EXTERNAL_DELEGATION") -package kotlinx.datetime.internal.JSJoda - -import kotlin.js.* -import kotlin.js.Json -import org.khronos.webgl.* -import org.w3c.dom.* -import org.w3c.dom.events.* -import org.w3c.dom.parsing.* -import org.w3c.dom.svg.* -import org.w3c.dom.url.* -import org.w3c.fetch.* -import org.w3c.files.* -import org.w3c.notifications.* -import org.w3c.performance.* -import org.w3c.workers.* -import org.w3c.xhr.* - -typealias Chronology = IsoChronology - -typealias DateTimeParseException = Error - -typealias DateTimeException = Error \ No newline at end of file diff --git a/core/js/src/kotlinx.datetime.internal.JSJoda.module_@js-joda_core.kt b/core/js/src/kotlinx.datetime.internal.JSJoda.module_@js-joda_core.kt index 7360d417..d2307c09 100644 --- a/core/js/src/kotlinx.datetime.internal.JSJoda.module_@js-joda_core.kt +++ b/core/js/src/kotlinx.datetime.internal.JSJoda.module_@js-joda_core.kt @@ -1,1254 +1,22 @@ @file:JsModule("@js-joda/core") -@file:JsNonModule +@file:kotlinx.datetime.internal.JsNonModule @file:Suppress("NO_EXPLICIT_VISIBILITY_IN_API_MODE", "INTERFACE_WITH_SUPERCLASS", "OVERRIDING_FINAL_MEMBER", "RETURN_TYPE_MISMATCH_ON_OVERRIDE", "CONFLICTING_OVERLOADS", "PARAMETER_NAME_CHANGED_ON_OVERRIDE") package kotlinx.datetime.internal.JSJoda +import kotlinx.datetime.internal.InteropInterface import kotlin.js.* -import org.khronos.webgl.* -import org.w3c.dom.* -import org.w3c.dom.events.* -import org.w3c.dom.parsing.* -import org.w3c.dom.svg.* -import org.w3c.dom.url.* -import org.w3c.fetch.* -import org.w3c.files.* -import org.w3c.notifications.* -import org.w3c.performance.* -import org.w3c.workers.* -import org.w3c.xhr.* - -external open class TemporalField { - open fun isSupportedBy(temporal: TemporalAccessor): Boolean - open fun isDateBased(): Boolean - open fun isTimeBased(): Boolean - open fun baseUnit(): TemporalUnit - open fun rangeUnit(): TemporalUnit - open fun range(): ValueRange - open fun rangeRefinedBy(temporal: TemporalAccessor): ValueRange - open fun getFrom(temporal: TemporalAccessor): Number - open fun adjustInto(temporal: R, newValue: Number): R - open fun name(): String - open fun displayName(): String - open fun equals(other: Any): Boolean -} - -external open class TemporalUnit { - open fun addTo(temporal: T, amount: Number): T - open fun between(temporal1: Temporal, temporal2: Temporal): Number - open fun duration(): Duration - open fun isDateBased(): Boolean - open fun isDurationEstimated(): Boolean - open fun isSupportedBy(temporal: Temporal): Boolean - open fun isTimeBased(): Boolean -} - -external open class ValueRange { - open fun checkValidValue(value: Number, field: TemporalField): Number - open fun checkValidIntValue(value: Number, field: TemporalField): Number - open fun equals(other: Any): Boolean - override fun hashCode(): Number - open fun isFixed(): Boolean - open fun isIntValue(): Boolean - open fun isValidIntValue(value: Number): Boolean - open fun isValidValue(value: Number): Boolean - open fun largestMinimum(): Number - open fun maximum(): Number - open fun minimum(): Number - open fun smallestMaximum(): Number - override fun toString(): String - - companion object { - fun of(min: Number, max: Number): ValueRange - fun of(min: Number, maxSmallest: Number, maxLargest: Number): ValueRange - fun of(minSmallest: Number, minLargest: Number, maxSmallest: Number, maxLargest: Number): ValueRange - } -} - -external open class TemporalAmount { - open fun addTo(temporal: T): T - open fun get(unit: TemporalUnit): Number - open fun units(): Array - open fun subtractFrom(temporal: T): T -} - -external open class TemporalAccessor { - open fun get(field: TemporalField): Number - open fun query(query: TemporalQuery): R? - open fun range(field: TemporalField): ValueRange - open fun getLong(field: TemporalField): Number - open fun isSupported(field: TemporalField): Boolean -} - -external open class Temporal : TemporalAccessor { - override fun isSupported(field: TemporalField): Boolean - open fun isSupported(unit: TemporalUnit): Boolean - open fun minus(amountToSubtract: Number, unit: TemporalUnit): Temporal - open fun minus(amount: TemporalAmount): Temporal - open fun plus(amountToAdd: Number, unit: TemporalUnit): Temporal - open fun plus(amount: TemporalAmount): Temporal - open fun until(endTemporal: Temporal, unit: TemporalUnit): Number - open fun with(adjuster: TemporalAdjuster): Temporal - open fun with(field: TemporalField, newValue: Number): Temporal -} - -external open class TemporalAdjuster { - open fun adjustInto(temporal: Temporal): Temporal -} - -external open class TemporalQuery { - open fun queryFrom(temporal: TemporalAccessor): R -} - -external open class ChronoField : TemporalField { - override fun isSupportedBy(temporal: TemporalAccessor): Boolean - override fun baseUnit(): TemporalUnit - open fun checkValidValue(value: Number): Number - open fun checkValidIntValue(value: Number): Number - override fun displayName(): String - override fun equals(other: Any): Boolean - override fun getFrom(temporal: TemporalAccessor): Number - override fun isDateBased(): Boolean - override fun isTimeBased(): Boolean - override fun name(): String - override fun range(): ValueRange - override fun rangeRefinedBy(temporal: TemporalAccessor): ValueRange - override fun rangeUnit(): TemporalUnit - override fun adjustInto(temporal: R, newValue: Number): R - override fun toString(): String - - companion object { - var ALIGNED_DAY_OF_WEEK_IN_MONTH: ChronoField - var ALIGNED_DAY_OF_WEEK_IN_YEAR: ChronoField - var ALIGNED_WEEK_OF_MONTH: ChronoField - var ALIGNED_WEEK_OF_YEAR: ChronoField - var AMPM_OF_DAY: ChronoField - var CLOCK_HOUR_OF_AMPM: ChronoField - var CLOCK_HOUR_OF_DAY: ChronoField - var DAY_OF_MONTH: ChronoField - var DAY_OF_WEEK: ChronoField - var DAY_OF_YEAR: ChronoField - var EPOCH_DAY: ChronoField - var ERA: ChronoField - var HOUR_OF_AMPM: ChronoField - var HOUR_OF_DAY: ChronoField - var INSTANT_SECONDS: ChronoField - var MICRO_OF_DAY: ChronoField - var MICRO_OF_SECOND: ChronoField - var MILLI_OF_DAY: ChronoField - var MILLI_OF_SECOND: ChronoField - var MINUTE_OF_DAY: ChronoField - var MINUTE_OF_HOUR: ChronoField - var MONTH_OF_YEAR: ChronoField - var NANO_OF_DAY: ChronoField - var NANO_OF_SECOND: ChronoField - var OFFSET_SECONDS: ChronoField - var PROLEPTIC_MONTH: ChronoField - var SECOND_OF_DAY: ChronoField - var SECOND_OF_MINUTE: ChronoField - var YEAR: ChronoField - var YEAR_OF_ERA: ChronoField - } -} - -external open class ChronoUnit : TemporalUnit { - override fun addTo(temporal: T, amount: Number): T - override fun between(temporal1: Temporal, temporal2: Temporal): Number - open fun compareTo(other: TemporalUnit): Number - override fun duration(): Duration - override fun isDateBased(): Boolean - override fun isDurationEstimated(): Boolean - override fun isSupportedBy(temporal: Temporal): Boolean - override fun isTimeBased(): Boolean - override fun toString(): String - - companion object { - var NANOS: ChronoUnit - var MICROS: ChronoUnit - var MILLIS: ChronoUnit - var SECONDS: ChronoUnit - var MINUTES: ChronoUnit - var HOURS: ChronoUnit - var HALF_DAYS: ChronoUnit - var DAYS: ChronoUnit - var WEEKS: ChronoUnit - var MONTHS: ChronoUnit - var YEARS: ChronoUnit - var DECADES: ChronoUnit - var CENTURIES: ChronoUnit - var MILLENNIA: ChronoUnit - var ERAS: ChronoUnit - var FOREVER: ChronoUnit - } -} - -external open class Clock { - open fun equals(other: Any): Boolean - open fun instant(): Instant - open fun millis(): Number - open fun withZone(zone: ZoneId): Clock - open fun zone(): ZoneId - - companion object { - fun fixed(fixedInstant: Instant, zoneId: ZoneId): Clock - fun offset(baseClock: Clock, offsetDuration: Duration): Clock - fun system(zone: ZoneId): Clock - fun systemDefaultZone(): Clock - fun systemUTC(): Clock - } -} - -external open class Duration : TemporalAmount { - open fun abs(): Duration - override fun addTo(temporal: T): T - open fun compareTo(otherDuration: Duration): Number - open fun dividedBy(divisor: Number): Duration - open fun equals(other: Any): Boolean - override fun get(unit: TemporalUnit): Number - open fun isNegative(): Boolean - open fun isZero(): Boolean - open fun minus(amount: Number, unit: TemporalUnit): Duration - open fun minus(duration: Duration): Duration - open fun minusDays(daysToSubtract: Number): Duration - open fun minusHours(hoursToSubtract: Number): Duration - open fun minusMillis(millisToSubtract: Number): Duration - open fun minusMinutes(minutesToSubtract: Number): Duration - open fun minusNanos(nanosToSubtract: Number): Duration - open fun minusSeconds(secondsToSubtract: Number): Duration - open fun multipliedBy(multiplicand: Number): Duration - open fun nano(): Number - open fun negated(): Duration - open fun plus(amount: Number, unit: TemporalUnit): Duration - open fun plus(duration: Duration): Duration - open fun plusDays(daysToAdd: Number): Duration - open fun plusHours(hoursToAdd: Number): Duration - open fun plusMillis(millisToAdd: Number): Duration - open fun plusMinutes(minutesToAdd: Number): Duration - open fun plusNanos(nanosToAdd: Number): Duration - open fun plusSeconds(secondsToAdd: Number): Duration - open fun plusSecondsNanos(secondsToAdd: Number, nanosToAdd: Number): Duration - open fun seconds(): Number - override fun subtractFrom(temporal: T): T - open fun toDays(): Number - open fun toHours(): Number - open fun toJSON(): String - open fun toMillis(): Number - open fun toMinutes(): Number - open fun toNanos(): Number - override fun toString(): String - override fun units(): Array - open fun withNanos(nanoOfSecond: Number): Duration - open fun withSeconds(seconds: Number): Duration - - companion object { - var ZERO: Duration - fun between(startInclusive: Temporal, endExclusive: Temporal): Duration - fun from(amount: TemporalAmount): Duration - fun of(amount: Number, unit: TemporalUnit): Duration - fun ofDays(days: Number): Duration - fun ofHours(hours: Number): Duration - fun ofMillis(millis: Number): Duration - fun ofMinutes(minutes: Number): Duration - fun ofNanos(nanos: Number): Duration - fun ofSeconds(seconds: Number, nanoAdjustment: Number = definedExternally): Duration - fun parse(text: String): Duration - } -} - -external open class Instant : Temporal { - open fun adjustInto(temporal: Temporal): Temporal - open fun atZone(zone: ZoneId): ZonedDateTime - open fun compareTo(otherInstant: Instant): Number - open fun epochSecond(): Number - open fun equals(other: Any): Boolean - override fun getLong(field: TemporalField): Number - override fun hashCode(): Number - open fun isAfter(otherInstant: Instant): Boolean - open fun isBefore(otherInstant: Instant): Boolean - override fun isSupported(fieldOrUnit: TemporalField): Boolean - override fun isSupported(fieldOrUnit: TemporalUnit): Boolean - override fun minus(amount: TemporalAmount): Instant - override fun minus(amountToSubtract: Number, unit: TemporalUnit): Instant - open fun minusMillis(millisToSubtract: Number): Instant - open fun minusNanos(nanosToSubtract: Number): Instant - open fun minusSeconds(secondsToSubtract: Number): Instant - open fun nano(): Number - override fun plus(amount: TemporalAmount): Instant - override fun plus(amountToAdd: Number, unit: TemporalUnit): Instant - open fun plusMillis(millisToAdd: Number): Instant - open fun plusNanos(nanosToAdd: Number): Instant - open fun plusSeconds(secondsToAdd: Number): Instant - open fun toEpochMilli(): Number - open fun toJSON(): String - override fun toString(): String - open fun truncatedTo(unit: TemporalUnit): Instant - override fun until(endExclusive: Temporal, unit: TemporalUnit): Number - override fun with(adjuster: TemporalAdjuster): Instant - override fun with(field: TemporalField, newValue: Number): Instant - - companion object { - var EPOCH: Instant - var MIN: Instant - var MAX: Instant - var MIN_SECONDS: Instant - var MAX_SECONDS: Instant - var FROM: TemporalQuery - fun from(temporal: TemporalAccessor): Instant - fun now(clock: Clock = definedExternally): Instant - fun ofEpochMilli(epochMilli: Number): Instant - fun ofEpochSecond(epochSecond: Number, nanoAdjustment: Number = definedExternally): Instant - fun parse(text: String): Instant - } -} - -external open class LocalDate : ChronoLocalDate { - open fun atStartOfDay(): LocalDateTime - open fun atStartOfDay(zone: ZoneId): ZonedDateTime - open fun atTime(hour: Number, minute: Number, second: Number = definedExternally, nanoOfSecond: Number = definedExternally): LocalDateTime - open fun atTime(hour: Number, minute: Number): LocalDateTime - open fun atTime(hour: Number, minute: Number, second: Number = definedExternally): LocalDateTime - open fun atTime(time: LocalTime): LocalDateTime - open fun chronology(): Chronology - open fun compareTo(other: LocalDate): Number - open fun dayOfMonth(): Number - open fun dayOfWeek(): DayOfWeek - open fun dayOfYear(): Number - open fun equals(other: Any): Boolean - override fun getLong(field: TemporalField): Number - override fun hashCode(): Number - open fun isAfter(other: LocalDate): Boolean - open fun isBefore(other: LocalDate): Boolean - open fun isEqual(other: LocalDate): Boolean - open fun isLeapYear(): Boolean - open fun isoWeekOfWeekyear(): Number - open fun isoWeekyear(): Number - override fun isSupported(fieldOrUnit: TemporalField): Boolean - override fun isSupported(fieldOrUnit: TemporalUnit): Boolean - open fun lengthOfMonth(): Number - open fun lengthOfYear(): Number - override fun minus(amount: TemporalAmount): LocalDate - override fun minus(amountToSubtract: Number, unit: TemporalUnit): LocalDate - open fun minusDays(daysToSubtract: Number): LocalDate - open fun minusMonths(monthsToSubtract: Number): LocalDate - open fun minusWeeks(weeksToSubtract: Number): LocalDate - open fun minusYears(yearsToSubtract: Number): LocalDate - open fun month(): Month - open fun monthValue(): Number - override fun plus(amount: TemporalAmount): LocalDate - override fun plus(amountToAdd: Number, unit: TemporalUnit): LocalDate - open fun plusDays(daysToAdd: Number): LocalDate - open fun plusMonths(monthsToAdd: Number): LocalDate - open fun plusWeeks(weeksToAdd: Number): LocalDate - open fun plusYears(yearsToAdd: Number): LocalDate - open fun toEpochDay(): Number - open fun toJSON(): String - override fun toString(): String - open fun until(endDate: TemporalAccessor): Period - override fun until(endExclusive: Temporal, unit: TemporalUnit): Number - override fun with(adjuster: TemporalAdjuster): LocalDate - override fun with(field: TemporalField, newValue: Number): LocalDate - open fun withDayOfMonth(dayOfMonth: Number): LocalDate - open fun withDayOfYear(dayOfYear: Number): LocalDate - open fun withMonth(month: Month): LocalDate - open fun withMonth(month: Number): LocalDate - open fun withYear(year: Number): LocalDate - open fun year(): Number - - companion object { - var MIN: LocalDate - var MAX: LocalDate - var EPOCH_0: LocalDate - var FROM: TemporalQuery - fun from(temporal: TemporalAccessor): LocalDate - fun now(clockOrZone: Clock = definedExternally): LocalDate - fun now(clockOrZone: ZoneId = definedExternally): LocalDate - fun of(year: Number, month: Month, dayOfMonth: Number): LocalDate - fun of(year: Number, month: Number, dayOfMonth: Number): LocalDate - fun ofEpochDay(epochDay: Number): LocalDate - fun ofInstant(instant: Instant, zoneId: ZoneId = definedExternally): LocalDate - fun ofYearDay(year: Number, dayOfYear: Number): LocalDate - fun parse(text: String, formatter: DateTimeFormatter = definedExternally): LocalDate - } -} - -external open class LocalDateTime : ChronoLocalDateTime { - open fun atOffset(offset: ZoneOffset): OffsetDateTime - open fun atZone(zone: ZoneId): ZonedDateTime - open fun compareTo(other: LocalDateTime): Number - open fun dayOfMonth(): Number - open fun dayOfWeek(): DayOfWeek - open fun dayOfYear(): Number - open fun equals(other: Any): Boolean - open fun format(formatter: DateTimeFormatter): String - override fun getLong(field: TemporalField): Number - override fun hashCode(): Number - open fun hour(): Number - open fun isAfter(other: LocalDateTime): Boolean - open fun isBefore(other: LocalDateTime): Boolean - open fun isEqual(other: LocalDateTime): Boolean - override fun isSupported(fieldOrUnit: TemporalField): Boolean - override fun isSupported(fieldOrUnit: TemporalUnit): Boolean - override fun minus(amount: TemporalAmount): LocalDateTime - override fun minus(amountToSubtract: Number, unit: TemporalUnit): LocalDateTime - open fun minusDays(days: Number): LocalDateTime - open fun minusHours(hours: Number): LocalDateTime - open fun minusMinutes(minutes: Number): LocalDateTime - open fun minusMonths(months: Number): LocalDateTime - open fun minusNanos(nanos: Number): LocalDateTime - open fun minusSeconds(seconds: Number): LocalDateTime - open fun minusWeeks(weeks: Number): LocalDateTime - open fun minusYears(years: Number): LocalDateTime - open fun minute(): Number - open fun month(): Month - open fun monthValue(): Number - open fun nano(): Number - override fun plus(amount: TemporalAmount): LocalDateTime - override fun plus(amountToAdd: Number, unit: TemporalUnit): LocalDateTime - open fun plusDays(days: Number): LocalDateTime - open fun plusHours(hours: Number): LocalDateTime - open fun plusMinutes(minutes: Number): LocalDateTime - open fun plusMonths(months: Number): LocalDateTime - open fun plusNanos(nanos: Number): LocalDateTime - open fun plusSeconds(seconds: Number): LocalDateTime - open fun plusWeeks(weeks: Number): LocalDateTime - open fun plusYears(years: Number): LocalDateTime - open fun second(): Number - open fun toJSON(): String - open fun toLocalDate(): LocalDate - open fun toLocalTime(): LocalTime - override fun toString(): String - open fun truncatedTo(unit: TemporalUnit): LocalDateTime - override fun until(endExclusive: Temporal, unit: TemporalUnit): Number - override fun with(adjuster: TemporalAdjuster): LocalDateTime - override fun with(field: TemporalField, newValue: Number): LocalDateTime - open fun withDayOfMonth(dayOfMonth: Number): LocalDateTime - open fun withDayOfYear(dayOfYear: Number): LocalDateTime - open fun withHour(hour: Number): LocalDateTime - open fun withMinute(minute: Number): LocalDateTime - open fun withMonth(month: Number): LocalDateTime - open fun withMonth(month: Month): LocalDateTime - open fun withNano(nanoOfSecond: Number): LocalDateTime - open fun withSecond(second: Number): LocalDateTime - open fun withYear(year: Number): LocalDateTime - open fun year(): Number - - companion object { - var MIN: LocalDateTime - var MAX: LocalDateTime - var FROM: TemporalQuery - fun from(temporal: TemporalAccessor): LocalDateTime - fun now(clockOrZone: Clock = definedExternally): LocalDateTime - fun now(clockOrZone: ZoneId = definedExternally): LocalDateTime - fun of(date: LocalDate, time: LocalTime): LocalDateTime - fun of(year: Number, month: Month, dayOfMonth: Number, hour: Number = definedExternally, minute: Number = definedExternally, second: Number = definedExternally, nanoSecond: Number = definedExternally): LocalDateTime - fun of(year: Number, month: Number, dayOfMonth: Number, hour: Number = definedExternally, minute: Number = definedExternally, second: Number = definedExternally, nanoSecond: Number = definedExternally): LocalDateTime - fun ofEpochSecond(epochSecond: Number, nanoOfSecond: Number, offset: ZoneOffset): LocalDateTime - fun ofEpochSecond(epochSecond: Number, offset: ZoneOffset): LocalDateTime - fun ofInstant(instant: Instant, zoneId: ZoneId = definedExternally): LocalDateTime - fun parse(text: String, formatter: DateTimeFormatter = definedExternally): LocalDateTime - } -} - -external open class LocalTime : Temporal { - open fun adjustInto(temporal: Temporal): Temporal - open fun atDate(date: LocalDate): LocalDateTime - open fun compareTo(other: LocalTime): Number - open fun equals(other: Any): Boolean - open fun format(formatter: DateTimeFormatter): String - open fun getLong(field: ChronoField): Number - override fun getLong(field: TemporalField): Number - override fun hashCode(): Number - open fun hour(): Number - open fun isAfter(other: LocalTime): Boolean - open fun isBefore(other: LocalTime): Boolean - override fun isSupported(fieldOrUnit: TemporalField): Boolean - override fun isSupported(fieldOrUnit: TemporalUnit): Boolean - override fun minus(amount: TemporalAmount): LocalTime - override fun minus(amountToSubtract: Number, unit: TemporalUnit): LocalTime - open fun minusHours(hoursToSubtract: Number): LocalTime - open fun minusMinutes(minutesToSubtract: Number): LocalTime - open fun minusNanos(nanosToSubtract: Number): LocalTime - open fun minusSeconds(secondsToSubtract: Number): LocalTime - open fun minute(): Number - open fun nano(): Number - override fun plus(amount: TemporalAmount): LocalTime - override fun plus(amountToAdd: Number, unit: TemporalUnit): LocalTime - open fun plusHours(hoursToAdd: Number): LocalTime - open fun plusMinutes(minutesToAdd: Number): LocalTime - open fun plusNanos(nanosToAdd: Number): LocalTime - open fun plusSeconds(secondstoAdd: Number): LocalTime - open fun second(): Number - open fun toJSON(): String - open fun toNanoOfDay(): Number - open fun toSecondOfDay(): Number - override fun toString(): String - open fun truncatedTo(unit: ChronoUnit): LocalTime - override fun until(endExclusive: Temporal, unit: TemporalUnit): Number - override fun with(adjuster: TemporalAdjuster): LocalTime - override fun with(field: TemporalField, newValue: Number): LocalTime - open fun withHour(hour: Number): LocalTime - open fun withMinute(minute: Number): LocalTime - open fun withNano(nanoOfSecond: Number): LocalTime - open fun withSecond(second: Number): LocalTime - - companion object { - var MIN: LocalTime - var MAX: LocalTime - var MIDNIGHT: LocalTime - var NOON: LocalTime - var HOURS_PER_DAY: Number - var MINUTES_PER_HOUR: Number - var MINUTES_PER_DAY: Number - var SECONDS_PER_MINUTE: Number - var SECONDS_PER_HOUR: Number - var SECONDS_PER_DAY: Number - var MILLIS_PER_DAY: Number - var MICROS_PER_DAY: Number - var NANOS_PER_SECOND: Number - var NANOS_PER_MINUTE: Number - var NANOS_PER_HOUR: Number - var NANOS_PER_DAY: Number - var FROM: TemporalQuery - fun from(temporal: TemporalAccessor): LocalTime - fun now(clockOrZone: Clock = definedExternally): LocalTime - fun now(clockOrZone: ZoneId = definedExternally): LocalTime - fun of(hour: Number = definedExternally, minute: Number = definedExternally, second: Number = definedExternally, nanoOfSecond: Number = definedExternally): LocalTime - fun ofInstant(instant: Instant, zone: ZoneId = definedExternally): LocalTime - fun ofNanoOfDay(nanoOfDay: Number): LocalTime - fun ofSecondOfDay(secondOfDay: Number = definedExternally, nanoOfSecond: Number = definedExternally): LocalTime - fun parse(text: String, formatter: DateTimeFormatter = definedExternally): LocalTime - } -} - -external open class MonthDay : TemporalAccessor { - open fun adjustInto(temporal: Temporal): Temporal - open fun atYear(year: Number): LocalDate - open fun compareTo(other: MonthDay): Number - open fun dayOfMonth(): Number - open fun equals(other: Any): Boolean - open fun format(formatter: DateTimeFormatter): String - override fun getLong(field: TemporalField): Number - open fun isAfter(other: MonthDay): Boolean - open fun isBefore(other: MonthDay): Boolean - override fun isSupported(field: TemporalField): Boolean - open fun isValidYear(year: Number): Boolean - open fun month(): Month - open fun monthValue(): Number - open fun toJSON(): String - override fun toString(): String - open fun with(month: Month): MonthDay - open fun withDayOfMonth(dayOfMonth: Number): MonthDay - open fun withMonth(month: Number): MonthDay - - companion object { - var FROM: TemporalQuery - fun from(temporal: TemporalAccessor): MonthDay - fun now(zoneIdOrClock: ZoneId = definedExternally): MonthDay - fun now(zoneIdOrClock: Clock = definedExternally): MonthDay - fun of(month: Month, dayOfMonth: Number): MonthDay - fun of(month: Number, dayOfMonth: Number): MonthDay - fun parse(text: String, formatter: DateTimeFormatter = definedExternally): MonthDay - } -} - -external open class Period : TemporalAmount { - override fun addTo(temporal: T): T - open fun chronology(): IsoChronology - open fun days(): Number - open fun equals(other: Any): Boolean - override fun get(unit: TemporalUnit): Number - override fun hashCode(): Number - open fun isNegative(): Boolean - open fun isZero(): Boolean - open fun minus(amountToSubtract: TemporalAmount): Period - open fun minusDays(daysToSubtract: Number): Period - open fun minusMonths(monthsToSubtract: Number): Period - open fun minusYears(yearsToSubtract: Number): Period - open fun months(): Number - open fun multipliedBy(scalar: Number): Period - open fun negated(): Period - open fun normalized(): Period - open fun plus(amountToAdd: TemporalAmount): Period - open fun plusDays(daysToAdd: Number): Period - open fun plusMonths(monthsToAdd: Number): Period - open fun plusYears(yearsToAdd: Number): Period - override fun subtractFrom(temporal: T): T - open fun toJSON(): String - override fun toString(): String - open fun toTotalMonths(): Number - override fun units(): Array - open fun withDays(days: Number): Period - open fun withMonths(months: Number): Period - open fun withYears(years: Number): Period - open fun years(): Number - - companion object { - var ZERO: Period - fun between(startDate: LocalDate, endDate: LocalDate): Period - fun from(amount: TemporalAmount): Period - fun of(years: Number, months: Number, days: Number): Period - fun ofDays(days: Number): Period - fun ofMonths(months: Number): Period - fun ofWeeks(weeks: Number): Period - fun ofYears(years: Number): Period - fun parse(text: String): Period - } -} - -external open class Year : Temporal { - open fun adjustInto(temporal: Temporal): Temporal - open fun atDay(dayOfYear: Number): LocalDate - open fun atMonth(month: Month): YearMonth - open fun atMonth(month: Number): YearMonth - open fun atMonthDay(monthDay: MonthDay): LocalDate - open fun compareTo(other: Year): Number - open fun equals(other: Any): Boolean - override fun getLong(field: TemporalField): Number - open fun isAfter(other: Year): Boolean - open fun isBefore(other: Year): Boolean - open fun isLeap(): Boolean - override fun isSupported(fieldOrUnit: TemporalField): Boolean - override fun isSupported(fieldOrUnit: TemporalUnit): Boolean - open fun isValidMonthDay(monthDay: MonthDay): Boolean - open fun length(): Number - override fun minus(amount: TemporalAmount): Year - override fun minus(amountToSubtract: Number, unit: TemporalUnit): Year - open fun minusYears(yearsToSubtract: Number): Year - override fun plus(amount: TemporalAmount): Year - override fun plus(amountToAdd: Number, unit: TemporalUnit): Year - open fun plusYears(yearsToAdd: Number): Year - open fun toJSON(): String - override fun toString(): String - override fun until(endExclusive: Temporal, unit: TemporalUnit): Number - open fun value(): Number - override fun with(adjuster: TemporalAdjuster): Year - override fun with(field: TemporalField, newValue: Number): Year - - companion object { - var MIN_VALUE: Number - var MAX_VALUE: Number - var FROM: TemporalQuery - fun from(temporal: TemporalAccessor): Year - fun isLeap(year: Number): Boolean - fun now(zoneIdOrClock: ZoneId = definedExternally): Year - fun now(zoneIdOrClock: Clock = definedExternally): Year - fun of(isoYear: Number): Year - fun parse(text: String, formatter: DateTimeFormatter = definedExternally): Year - } -} - -external open class YearMonth : Temporal { - open fun adjustInto(temporal: Temporal): Temporal - open fun atDay(dayOfMonth: Number): LocalDate - open fun atEndOfMonth(): LocalDate - open fun compareTo(other: YearMonth): Number - open fun equals(other: Any): Boolean - open fun format(formatter: DateTimeFormatter): String - override fun getLong(field: TemporalField): Number - open fun isAfter(other: YearMonth): Boolean - open fun isBefore(other: YearMonth): Boolean - open fun isLeapYear(): Boolean - override fun isSupported(fieldOrUnit: TemporalField): Boolean - override fun isSupported(fieldOrUnit: TemporalUnit): Boolean - open fun isValidDay(): Boolean - open fun lengthOfMonth(): Number - open fun lengthOfYear(): Number - override fun minus(amount: TemporalAmount): YearMonth - override fun minus(amountToSubtract: Number, unit: TemporalUnit): YearMonth - open fun minusMonths(monthsToSubtract: Number): YearMonth - open fun minusYears(yearsToSubtract: Number): YearMonth - open fun month(): Month - open fun monthValue(): Number - override fun plus(amount: TemporalAmount): YearMonth - override fun plus(amountToAdd: Number, unit: TemporalUnit): YearMonth - open fun plusMonths(monthsToAdd: Number): YearMonth - open fun plusYears(yearsToAdd: Number): YearMonth - open fun toJSON(): String - override fun until(endExclusive: Temporal, unit: TemporalUnit): Number - override fun with(adjuster: TemporalAdjuster): YearMonth - override fun with(field: TemporalField, newValue: Number): YearMonth - open fun withMonth(month: Number): YearMonth - open fun withYear(year: Number): YearMonth - open fun year(): Number - - companion object { - var FROM: TemporalQuery - fun from(temporal: TemporalAccessor): YearMonth - fun now(zoneIdOrClock: ZoneId = definedExternally): YearMonth - fun now(zoneIdOrClock: Clock = definedExternally): YearMonth - fun of(year: Number, monthOrNumber: Month): YearMonth - fun of(year: Number, monthOrNumber: Number): YearMonth - fun parse(text: String, formatter: DateTimeFormatter = definedExternally): YearMonth - } -} - -external open class OffsetDateTime : Temporal { - open fun adjustInto(temporal: Temporal): Temporal - open fun atZoneSameInstant(zone: ZoneId): ZonedDateTime - open fun atZoneSimilarLocal(zone: ZoneId): ZonedDateTime - open fun compareTo(other: OffsetDateTime): Number - open fun equals(obj: Any): Boolean - open fun format(formatter: DateTimeFormatter): String - override fun get(field: TemporalField): Number - open fun dayOfMonth(): Number - open fun dayOfWeek(): DayOfWeek - open fun dayOfYear(): Number - open fun hour(): Number - override fun getLong(field: TemporalField): Number - open fun minute(): Number - open fun month(): Month - open fun monthValue(): Number - open fun nano(): Number - open fun offset(): ZoneOffset - open fun second(): Number - open fun year(): Number - override fun hashCode(): Number - open fun isAfter(other: OffsetDateTime): Boolean - open fun isBefore(other: OffsetDateTime): Boolean - open fun isEqual(other: OffsetDateTime): Boolean - override fun isSupported(fieldOrUnit: TemporalField): Boolean - override fun isSupported(fieldOrUnit: TemporalUnit): Boolean - override fun minus(amountToSubtract: Number, unit: TemporalUnit): OffsetDateTime - override fun minus(amountToSubtract: TemporalAmount): OffsetDateTime - open fun minusDays(days: Number): OffsetDateTime - open fun minusHours(hours: Number): OffsetDateTime - open fun minusMinutes(minutes: Number): OffsetDateTime - open fun minusMonths(months: Number): OffsetDateTime - open fun minusNanos(nanos: Number): OffsetDateTime - open fun minusSeconds(seconds: Number): OffsetDateTime - open fun minusWeeks(weeks: Number): OffsetDateTime - open fun minusYears(years: Number): OffsetDateTime - override fun plus(amountToAdd: Number, unit: TemporalUnit): OffsetDateTime - override fun plus(amountToAdd: TemporalAmount): OffsetDateTime - open fun plusDays(days: Number): OffsetDateTime - open fun plusHours(hours: Number): OffsetDateTime - open fun plusMinutes(minutes: Number): OffsetDateTime - open fun plusMonths(months: Number): OffsetDateTime - open fun plusNanos(nanos: Number): OffsetDateTime - open fun plusSeconds(seconds: Number): OffsetDateTime - open fun plusWeeks(weeks: Number): OffsetDateTime - open fun plusYears(years: Number): OffsetDateTime - override fun query(query: TemporalQuery): R? - override fun range(field: TemporalField): ValueRange - open fun toEpochSecond(): Number - open fun toJSON(): String - open fun toInstant(): Instant - open fun toLocalDate(): LocalDate - open fun toLocalDateTime(): LocalDateTime - open fun toLocalTime(): LocalTime - open fun toOffsetTime(): OffsetTime - override fun toString(): String - open fun truncatedTo(unit: TemporalUnit): OffsetDateTime - override fun until(endExclusive: Temporal, unit: TemporalUnit): Number - override fun with(adjuster: TemporalAdjuster): OffsetDateTime - override fun with(field: TemporalField, newValue: Number): OffsetDateTime - open fun withDayOfMonth(dayOfMonth: Number): OffsetDateTime - open fun withDayOfYear(dayOfYear: Number): OffsetDateTime - open fun withHour(hour: Number): OffsetDateTime - open fun withMinute(minute: Number): OffsetDateTime - open fun withMonth(month: Number): OffsetDateTime - open fun withNano(nanoOfSecond: Number): OffsetDateTime - open fun withOffsetSameInstant(offset: ZoneOffset): OffsetDateTime - open fun withOffsetSameLocal(offset: ZoneOffset): OffsetDateTime - open fun withSecond(second: Number): OffsetDateTime - open fun withYear(year: Number): OffsetDateTime - - companion object { - var MIN: OffsetDateTime - var MAX: OffsetDateTime - var FROM: TemporalQuery - fun from(temporal: TemporalAccessor): OffsetDateTime - fun now(clockOrZone: Clock = definedExternally): OffsetDateTime - fun now(clockOrZone: ZoneId = definedExternally): OffsetDateTime - fun of(dateTime: LocalDateTime, offset: ZoneOffset): OffsetDateTime - fun of(date: LocalDate, time: LocalTime, offset: ZoneOffset): OffsetDateTime - fun of(year: Number, month: Number, day: Number, hour: Number, minute: Number, second: Number, nanoOfSecond: Number, offset: ZoneOffset): OffsetDateTime - fun ofInstant(instant: Instant, zone: ZoneId): OffsetDateTime - fun parse(text: String, formatter: DateTimeFormatter = definedExternally): OffsetDateTime - } -} - -external open class OffsetTime : Temporal { - open fun adjustInto(temporal: Temporal): Temporal - open fun atDate(date: LocalDate): OffsetDateTime - open fun compareTo(other: OffsetTime): Number - open fun equals(other: Any): Boolean - open fun format(formatter: DateTimeFormatter): String - override fun get(field: TemporalField): Number - open fun hour(): Number - override fun getLong(field: TemporalField): Number - open fun minute(): Number - open fun nano(): Number - open fun offset(): ZoneOffset - open fun second(): Number - override fun hashCode(): Number - open fun isAfter(other: OffsetTime): Boolean - open fun isBefore(other: OffsetTime): Boolean - open fun isEqual(other: OffsetTime): Boolean - override fun isSupported(fieldOrUnit: TemporalField): Boolean - override fun isSupported(fieldOrUnit: TemporalUnit): Boolean - override fun minus(amountToSubtract: Number, unit: TemporalUnit): OffsetTime - override fun minus(amountToSubtract: TemporalAmount): OffsetTime - open fun minusHours(hours: Number): OffsetTime - open fun minusMinutes(minutes: Number): OffsetTime - open fun minusNanos(nanos: Number): OffsetTime - open fun minusSeconds(seconds: Number): OffsetTime - override fun plus(amountToAdd: Number, unit: TemporalUnit): OffsetTime - override fun plus(amountToAdd: TemporalAmount): OffsetTime - open fun plusHours(hours: Number): OffsetTime - open fun plusMinutes(minutes: Number): OffsetTime - open fun plusNanos(nanos: Number): OffsetTime - open fun plusSeconds(seconds: Number): OffsetTime - override fun query(query: TemporalQuery): R? - override fun range(field: TemporalField): ValueRange - open fun toEpochSecond(date: LocalDate): Number - open fun toJSON(): String - open fun toLocalTime(): LocalTime - override fun toString(): String - open fun truncatedTo(unit: TemporalUnit): OffsetTime - override fun until(endExclusive: Temporal, unit: TemporalUnit): Number - override fun with(adjuster: TemporalAdjuster): OffsetTime - override fun with(field: TemporalField, newValue: Number): OffsetTime - open fun withHour(hour: Number): OffsetTime - open fun withMinute(minute: Number): OffsetTime - open fun withNano(nanoOfSecond: Number): OffsetTime - open fun withOffsetSameInstant(offset: ZoneOffset): OffsetTime - open fun withOffsetSameLocal(offset: ZoneOffset): OffsetTime - open fun withSecond(second: Number): OffsetTime - - companion object { - var MIN: OffsetTime - var MAX: OffsetTime - var FROM: TemporalQuery - fun from(temporal: TemporalAccessor): OffsetTime - fun now(clockOrZone: Clock = definedExternally): OffsetTime - fun now(clockOrZone: ZoneId = definedExternally): OffsetTime - fun of(time: LocalTime, offset: ZoneOffset): OffsetTime - fun of(hour: Number, minute: Number, second: Number, nanoOfSecond: Number, offset: ZoneOffset): OffsetTime - fun ofInstant(instant: Instant, zone: ZoneId): OffsetTime - fun parse(text: String, formatter: DateTimeFormatter = definedExternally): OffsetTime - } -} - -external open class ZonedDateTime : ChronoZonedDateTime { - open fun dayOfMonth(): Number - open fun dayOfWeek(): DayOfWeek - open fun dayOfYear(): Number - override fun equals(other: Any): Boolean - override fun format(formatter: DateTimeFormatter): String - override fun getLong(field: TemporalField): Number - override fun hashCode(): Number - open fun hour(): Number - override fun isSupported(fieldOrUnit: TemporalField): Boolean - override fun isSupported(fieldOrUnit: TemporalUnit): Boolean - override fun minus(amount: TemporalAmount): ZonedDateTime - override fun minus(amountToSubtract: Number, unit: TemporalUnit): ZonedDateTime - open fun minusDays(days: Number): ZonedDateTime - open fun minusHours(hours: Number): ZonedDateTime - open fun minusMinutes(minutes: Number): ZonedDateTime - open fun minusMonths(months: Number): ZonedDateTime - open fun minusNanos(nanos: Number): ZonedDateTime - open fun minusSeconds(seconds: Number): ZonedDateTime - open fun minusWeeks(weeks: Number): ZonedDateTime - open fun minusYears(years: Number): ZonedDateTime - open fun minute(): Number - open fun month(): Month - open fun monthValue(): Number - open fun nano(): Number - open fun offset(): ZoneOffset - override fun plus(amount: TemporalAmount): ZonedDateTime - override fun plus(amountToAdd: Number, unit: TemporalUnit): ZonedDateTime - open fun plusDays(days: Number): ZonedDateTime - open fun plusHours(hours: Number): ZonedDateTime - open fun plusMinutes(minutes: Number): ZonedDateTime - open fun plusMonths(months: Number): ZonedDateTime - open fun plusNanos(nanos: Number): ZonedDateTime - open fun plusSeconds(seconds: Number): ZonedDateTime - open fun plusWeeks(weeks: Number): ZonedDateTime - open fun plusYears(years: Number): ZonedDateTime - override fun range(field: TemporalField): ValueRange - open fun second(): Number - open fun toJSON(): String - open fun toLocalDate(): LocalDate - open fun toLocalDateTime(): LocalDateTime - open fun toLocalTime(): LocalTime - open fun toOffsetDateTime(): OffsetDateTime - override fun toString(): String - open fun truncatedTo(unit: TemporalUnit): ZonedDateTime - override fun until(endExclusive: Temporal, unit: TemporalUnit): Number - override fun with(adjuster: TemporalAdjuster): ZonedDateTime - override fun with(field: TemporalField, newValue: Number): ZonedDateTime - open fun withDayOfMonth(dayOfMonth: Number): ZonedDateTime - open fun withDayOfYear(dayOfYear: Number): ZonedDateTime - open fun withEarlierOffsetAtOverlap(): ZonedDateTime - open fun withFixedOffsetZone(): ZonedDateTime - open fun withHour(hour: Number): ZonedDateTime - open fun withLaterOffsetAtOverlap(): ZonedDateTime - open fun withMinute(minute: Number): ZonedDateTime - open fun withMonth(month: Number): ZonedDateTime - open fun withNano(nanoOfSecond: Number): ZonedDateTime - open fun withSecond(second: Number): ZonedDateTime - open fun withYear(year: Number): ZonedDateTime - open fun withZoneSameInstant(zone: ZoneId): ZonedDateTime - open fun withZoneSameLocal(zone: ZoneId): ZonedDateTime - open fun year(): Number - open fun zone(): ZoneId - - companion object { - var FROM: TemporalQuery - fun from(temporal: TemporalAccessor): ZonedDateTime - fun now(clockOrZone: Clock = definedExternally): ZonedDateTime - fun now(clockOrZone: ZoneId = definedExternally): ZonedDateTime - fun of(localDateTime: LocalDateTime, zone: ZoneId): ZonedDateTime - fun of(date: LocalDate, time: LocalTime, zone: ZoneId): ZonedDateTime - fun of(year: Number, month: Number, dayOfMonth: Number, hour: Number, minute: Number, second: Number, nanoOfSecond: Number, zone: ZoneId): ZonedDateTime - fun ofInstant(instant: Instant, zone: ZoneId): ZonedDateTime - fun ofInstant(localDateTime: LocalDateTime, offset: ZoneOffset, zone: ZoneId): ZonedDateTime - fun ofLocal(localDateTime: LocalDateTime, zone: ZoneId, preferredOffset: ZoneOffset? = definedExternally): ZonedDateTime - fun ofStrict(localDateTime: LocalDateTime, offset: ZoneOffset, zone: ZoneId): ZonedDateTime - fun parse(text: String, formatter: DateTimeFormatter = definedExternally): ZonedDateTime - } -} - -external open class ZoneId { - open fun equals(other: Any): Boolean - override fun hashCode(): Number - open fun id(): String - open fun normalized(): ZoneId - open fun rules(): ZoneRules - open fun toJSON(): String - override fun toString(): String - - companion object { - var SYSTEM: ZoneId - var UTC: ZoneId - fun systemDefault(): ZoneId - fun of(zoneId: String): ZoneId - fun ofOffset(prefix: String, offset: ZoneOffset): ZoneId - fun from(temporal: TemporalAccessor): ZoneId - fun getAvailableZoneIds(): Array - } -} - -external open class ZoneOffset : ZoneId { - open fun adjustInto(temporal: Temporal): Temporal - open fun compareTo(other: ZoneOffset): Number - override fun equals(other: Any): Boolean - open fun get(field: TemporalField): Number - open fun getLong(field: TemporalField): Number - override fun hashCode(): Number - override fun id(): String - override fun rules(): ZoneRules - override fun toString(): String - open fun totalSeconds(): Number - - companion object { - var MAX_SECONDS: ZoneOffset - var UTC: ZoneOffset - var MIN: ZoneOffset - var MAX: ZoneOffset - fun of(offsetId: String): ZoneOffset - fun ofHours(hours: Number): ZoneOffset - fun ofHoursMinutes(hours: Number, minutes: Number): ZoneOffset - fun ofHoursMinutesSeconds(hours: Number, minutes: Number, seconds: Number): ZoneOffset - fun ofTotalMinutes(totalMinutes: Number): ZoneOffset - fun ofTotalSeconds(totalSeconds: Number): ZoneOffset - } -} - -external open class ZoneRegion : ZoneId { - override fun id(): String - override fun rules(): ZoneRules - - companion object { - fun ofId(zoneId: String): ZoneId - } -} - -external open class DayOfWeek : TemporalAccessor { - open fun adjustInto(temporal: Temporal): Temporal - open fun compareTo(other: DayOfWeek): Number - open fun equals(other: Any): Boolean - open fun displayName(style: TextStyle, locale: Locale): String - override fun getLong(field: TemporalField): Number - override fun isSupported(field: TemporalField): Boolean - open fun minus(days: Number): DayOfWeek - open fun name(): String - open fun ordinal(): Number - open fun plus(days: Number): DayOfWeek - open fun toJSON(): String - override fun toString(): String - open fun value(): Number - - companion object { - var MONDAY: DayOfWeek - var TUESDAY: DayOfWeek - var WEDNESDAY: DayOfWeek - var THURSDAY: DayOfWeek - var FRIDAY: DayOfWeek - var SATURDAY: DayOfWeek - var SUNDAY: DayOfWeek - var FROM: TemporalQuery - fun from(temporal: TemporalAccessor): DayOfWeek - fun of(dayOfWeek: Number): DayOfWeek - fun valueOf(name: String): DayOfWeek - fun values(): Array - } -} - -external open class Month : TemporalAccessor { - open fun adjustInto(temporal: Temporal): Temporal - open fun compareTo(other: Month): Number - open fun equals(other: Any): Boolean - open fun firstDayOfYear(leapYear: Boolean): Number - open fun firstMonthOfQuarter(): Month - open fun displayName(style: TextStyle, locale: Locale): String - override fun getLong(field: TemporalField): Number - override fun isSupported(field: TemporalField): Boolean - open fun length(leapYear: Boolean): Number - open fun maxLength(): Number - open fun minLength(): Number - open fun minus(months: Number): Month - open fun name(): String - open fun ordinal(): Number - open fun plus(months: Number): Month - open fun toJSON(): String - override fun toString(): String - open fun value(): Number - - companion object { - var JANUARY: Month - var FEBRUARY: Month - var MARCH: Month - var APRIL: Month - var MAY: Month - var JUNE: Month - var JULY: Month - var AUGUST: Month - var SEPTEMBER: Month - var OCTOBER: Month - var NOVEMBER: Month - var DECEMBER: Month - fun from(temporal: TemporalAccessor): Month - fun of(month: Number): Month - fun valueOf(name: String): Month - fun values(): Array - } -} - -external open class DateTimeFormatter { - open fun chronology(): Chronology? - open fun decimalStyle(): DecimalStyle - open fun format(temporal: TemporalAccessor): String - open fun locale(): Any - open fun parse(text: String): TemporalAccessor - open fun parse(text: String, query: TemporalQuery): T - open fun parseUnresolved(text: String, position: ParsePosition): TemporalAccessor - override fun toString(): String - open fun withChronology(chrono: Chronology): DateTimeFormatter - open fun withLocale(locale: Locale): DateTimeFormatter - open fun withResolverStyle(resolverStyle: ResolverStyle): DateTimeFormatter - - companion object { - var ISO_LOCAL_DATE: DateTimeFormatter - var ISO_LOCAL_TIME: DateTimeFormatter - var ISO_LOCAL_DATE_TIME: DateTimeFormatter - var ISO_INSTANT: DateTimeFormatter - var ISO_OFFSET_DATE_TIME: DateTimeFormatter - var ISO_ZONED_DATE_TIME: DateTimeFormatter - fun ofPattern(pattern: String): DateTimeFormatter - fun parsedExcessDays(): TemporalQuery - fun parsedLeapSecond(): TemporalQuery - } -} - -external open class DateTimeFormatterBuilder { - open fun append(formatter: DateTimeFormatter): DateTimeFormatterBuilder - open fun appendFraction(field: TemporalField, minWidth: Number, maxWidth: Number, decimalPoint: Boolean): DateTimeFormatterBuilder - open fun appendInstant(fractionalDigits: Number): DateTimeFormatterBuilder - open fun appendLiteral(literal: Any): DateTimeFormatterBuilder - open fun appendOffset(pattern: String, noOffsetText: String): DateTimeFormatterBuilder - open fun appendOffsetId(): DateTimeFormatterBuilder - open fun appendPattern(pattern: String): DateTimeFormatterBuilder - open fun appendValue(field: TemporalField, width: Number = definedExternally, maxWidth: Number = definedExternally, signStyle: SignStyle = definedExternally): DateTimeFormatterBuilder - open fun appendValueReduced(field: TemporalField, width: Number, maxWidth: Number, base: ChronoLocalDate): DateTimeFormatterBuilder - open fun appendValueReduced(field: TemporalField, width: Number, maxWidth: Number, base: Number): DateTimeFormatterBuilder - open fun appendZoneId(): DateTimeFormatterBuilder - open fun optionalEnd(): DateTimeFormatterBuilder - open fun optionalStart(): DateTimeFormatterBuilder - open fun padNext(): DateTimeFormatterBuilder - open fun parseCaseInsensitive(): DateTimeFormatterBuilder - open fun parseCaseSensitive(): DateTimeFormatterBuilder - open fun parseLenient(): DateTimeFormatterBuilder - open fun parseStrict(): DateTimeFormatterBuilder - open fun toFormatter(resolverStyle: ResolverStyle = definedExternally): DateTimeFormatter -} - -external open class DecimalStyle { - open fun decimalSeparator(): String - open fun equals(other: Any): Boolean - override fun hashCode(): Any - open fun negativeSign(): String - open fun positiveSign(): String - override fun toString(): String - open fun zeroDigit(): String -} - -external open class ResolverStyle { - open fun equals(other: Any): Boolean - open fun toJSON(): String - override fun toString(): String - - companion object { - var STRICT: ResolverStyle - var SMART: ResolverStyle - var LENIENT: ResolverStyle - } -} - -external open class SignStyle { - open fun equals(other: Any): Boolean - open fun toJSON(): String - override fun toString(): String - - companion object { - var NORMAL: SignStyle - var NEVER: SignStyle - var ALWAYS: SignStyle - var EXCEEDS_PAD: SignStyle - var NOT_NEGATIVE: SignStyle - } -} - -external open class TextStyle { - open fun asNormal(): TextStyle - open fun asStandalone(): TextStyle - open fun isStandalone(): Boolean - open fun equals(other: Any): Boolean - open fun toJSON(): String - override fun toString(): String - - companion object { - var FULL: TextStyle - var FULL_STANDALONE: TextStyle - var SHORT: TextStyle - var SHORT_STANDALONE: TextStyle - var NARROW: TextStyle - var NARROW_STANDALONE: TextStyle - } -} - -external open class ParsePosition(index: Number) { - open fun getIndex(): Number - open fun setIndex(index: Number) - open fun getErrorIndex(): Number - open fun setErrorIndex(errorIndex: Number) -} - -external open class ZoneOffsetTransition { - open fun compareTo(transition: ZoneOffsetTransition): Number - open fun dateTimeAfter(): LocalDateTime - open fun dateTimeBefore(): LocalDateTime - open fun duration(): Duration - open fun durationSeconds(): Number - open fun equals(other: Any): Boolean - override fun hashCode(): Number - open fun instant(): Instant - open fun isGap(): Boolean - open fun isOverlap(): Boolean - open fun isValidOffset(offset: ZoneOffset): Boolean - open fun offsetAfter(): ZoneOffset - open fun offsetBefore(): ZoneOffset - open fun toEpochSecond(): Number - override fun toString(): String - open fun validOffsets(): Array - - companion object { - fun of(transition: LocalDateTime, offsetBefore: ZoneOffset, offsetAfter: ZoneOffset): ZoneOffsetTransition - } -} - -external interface ZoneOffsetTransitionRule - -external open class ZoneRules { - open fun offset(instant: Instant): ZoneOffset - open fun offset(localDateTime: LocalDateTime): ZoneOffset - open fun toJSON(): String - open fun daylightSavings(instant: Instant): Duration - open fun isDaylightSavings(instant: Instant): Boolean - open fun isFixedOffset(): Boolean - open fun isValidOffset(localDateTime: LocalDateTime, offset: ZoneOffset): Boolean - open fun nextTransition(instant: Instant): ZoneOffsetTransition - open fun offsetOfEpochMilli(epochMilli: Number): ZoneOffset - open fun offsetOfInstant(instant: Instant): ZoneOffset - open fun offsetOfLocalDateTime(localDateTime: LocalDateTime): ZoneOffset - open fun previousTransition(instant: Instant): ZoneOffsetTransition - open fun standardOffset(instant: Instant): ZoneOffset - override fun toString(): String - open fun transition(localDateTime: LocalDateTime): ZoneOffsetTransition - open fun transitionRules(): Array - open fun transitions(): Array - open fun validOffsets(localDateTime: LocalDateTime): Array - - companion object { - fun of(offest: ZoneOffset): ZoneRules - } -} - -external open class ZoneRulesProvider { - companion object { - fun getRules(zoneId: String): ZoneRules - fun getAvailableZoneIds(): Array - } -} - -external open class IsoChronology { - open fun equals(other: Any): Boolean - open fun resolveDate(fieldValues: Any, resolverStyle: Any): Any - override fun toString(): String - - companion object { - fun isLeapYear(prolepticYear: Number): Boolean - } -} - -external open class ChronoLocalDate : Temporal { - open fun adjustInto(temporal: Temporal): Temporal - open fun format(formatter: DateTimeFormatter): String - override fun isSupported(fieldOrUnit: TemporalField): Boolean - override fun isSupported(fieldOrUnit: TemporalUnit): Boolean -} - -external open class ChronoLocalDateTime : Temporal { - open fun adjustInto(temporal: Temporal): Temporal - open fun chronology(): Chronology - open fun toEpochSecond(offset: ZoneOffset): Number - open fun toInstant(offset: ZoneOffset): Instant -} - -external open class ChronoZonedDateTime : Temporal { - open fun compareTo(other: ChronoZonedDateTime): Number - open fun equals(other: Any): Boolean - open fun format(formatter: DateTimeFormatter): String - open fun isAfter(other: ChronoZonedDateTime): Boolean - open fun isBefore(other: ChronoZonedDateTime): Boolean - open fun isEqual(other: ChronoZonedDateTime): Boolean - open fun toEpochSecond(): Number - open fun toInstant(): Instant -} - -external interface Locale external fun nativeJs(date: Date, zone: ZoneId = definedExternally): TemporalAccessor external fun nativeJs(date: Date): TemporalAccessor -external fun nativeJs(date: Any, zone: ZoneId = definedExternally): TemporalAccessor +external fun nativeJs(date: InteropInterface, zone: ZoneId = definedExternally): TemporalAccessor -external fun nativeJs(date: Any): TemporalAccessor +external fun nativeJs(date: InteropInterface): TemporalAccessor -external interface `T$0` { +external interface `T$0` : InteropInterface { var toDate: () -> Date - var toEpochMilli: () -> Number + var toEpochMilli: () -> Double } external fun convert(temporal: LocalDate, zone: ZoneId = definedExternally): `T$0` @@ -1261,6 +29,4 @@ external fun convert(temporal: LocalDateTime): `T$0` external fun convert(temporal: ZonedDateTime, zone: ZoneId = definedExternally): `T$0` -external fun convert(temporal: ZonedDateTime): `T$0` - -external fun use(plugin: Function<*>): Any \ No newline at end of file +external fun convert(temporal: ZonedDateTime): `T$0` \ No newline at end of file diff --git a/core/wasmJs/src/JSJodaExceptions.kt b/core/wasmJs/src/JSJodaExceptions.kt new file mode 100644 index 00000000..4f836904 --- /dev/null +++ b/core/wasmJs/src/JSJodaExceptions.kt @@ -0,0 +1,43 @@ +/* + * Copyright 2019-2020 JetBrains s.r.o. + * Use of this source code is governed by the Apache 2.0 License that can be found in the LICENSE.txt file. + */ + +package kotlinx.datetime + +private fun checkExceptionName(exception: JsAny, name: String): Boolean = + js("exception.name === name") + +internal actual fun Throwable.hasJsExceptionName(name: String): Boolean { + val cause = (this as? JsException)?.jsException ?: return false + return checkExceptionName(cause, name) +} + +private fun withCaughtJsException(body: () -> Unit): JsAny? = js("""{ + try { + body(); + return null; + } catch(e) { + return e; + } +}""") + +private fun getExceptionMessage(jsException: JsAny): String? = js("jsException.message") + +internal class JsException(val jsException: JsAny): Throwable() { + override val message: String? + get() = getExceptionMessage(jsException) +} + +internal actual inline fun jsTry(crossinline body: () -> T): T { + var result: T? = null + val exception = withCaughtJsException { + result = body() + } + + if (exception != null) { + throw JsException(exception) + } else { + return result as T + } +} \ No newline at end of file diff --git a/core/wasmJs/src/PlatformSpecifics.kt b/core/wasmJs/src/PlatformSpecifics.kt new file mode 100644 index 00000000..95e2fa35 --- /dev/null +++ b/core/wasmJs/src/PlatformSpecifics.kt @@ -0,0 +1,18 @@ +/* + * Copyright 2019-2023 JetBrains s.r.o. and contributors. + * Use of this source code is governed by the Apache 2.0 License that can be found in the LICENSE.txt file. + */ +package kotlinx.datetime.internal + +import kotlinx.datetime.internal.JSJoda.ZoneId + +internal actual fun getAvailableZoneIdsSet(): Set = buildSet { + val ids = ZoneId.getAvailableZoneIds().unsafeCast>() + for (i in 0 until ids.length) { + add(ids[i].toString()) + } +} + +public actual typealias InteropInterface = JsAny + +public actual typealias JsModule = kotlin.js.JsModule \ No newline at end of file diff --git a/core/wasmJs/test/JsJodaTimeZoneModule.kt b/core/wasmJs/test/JsJodaTimeZoneModule.kt new file mode 100644 index 00000000..08b2aab1 --- /dev/null +++ b/core/wasmJs/test/JsJodaTimeZoneModule.kt @@ -0,0 +1,11 @@ +/* + * Copyright 2019-2020 JetBrains s.r.o. + * Use of this source code is governed by the Apache 2.0 License that can be found in the LICENSE.txt file. + */ + +package kotlinx.datetime.test + +@JsModule("@js-joda/timezone") +external object JsJodaTimeZoneModule + +private val jsJodaTz = JsJodaTimeZoneModule \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index efeb55f5..e1bcebc9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,7 +7,7 @@ versionSuffix=SNAPSHOT defaultKotlinVersion=1.9.21 dokkaVersion=1.8.20 -serializationVersion=1.5.1 +serializationVersion=1.6.2 java.mainToolchainVersion=8 java.modularToolchainVersion=11 diff --git a/serialization/build.gradle.kts b/serialization/build.gradle.kts index 1b503236..a3e1e911 100644 --- a/serialization/build.gradle.kts +++ b/serialization/build.gradle.kts @@ -51,6 +51,12 @@ kotlin { } } + + wasmJs { + nodejs { + } + } + sourceSets.all { val suffixIndex = name.indexOfLast { it.isUpperCase() } val targetName = name.substring(0, suffixIndex) @@ -97,7 +103,14 @@ kotlin { } } + val wasmJsMain by getting + val wasmJsTest by getting { + dependencies { + implementation(npm("@js-joda/timezone", "2.3.0")) + } + } + val nativeMain by getting val nativeTest by getting } -} +} \ No newline at end of file diff --git a/serialization/wasmJs/test/JsJodaTimeZoneModule.kt b/serialization/wasmJs/test/JsJodaTimeZoneModule.kt new file mode 100644 index 00000000..f2f86d85 --- /dev/null +++ b/serialization/wasmJs/test/JsJodaTimeZoneModule.kt @@ -0,0 +1,11 @@ +/* + * Copyright 2019-2020 JetBrains s.r.o. + * Use of this source code is governed by the Apache 2.0 License that can be found in the LICENSE.txt file. + */ + +package kotlinx.datetime.serialization.test + +@JsModule("@js-joda/timezone") +external object JsJodaTimeZoneModule + +private val jsJodaTz = JsJodaTimeZoneModule \ No newline at end of file