From c1123a3e603389e21cdb1080d5572cb697aa9476 Mon Sep 17 00:00:00 2001 From: Dmitry Khalanskiy Date: Fri, 1 Mar 2024 12:54:48 +0100 Subject: [PATCH 1/2] Attempt to also restore binary compatibility for Native Fixes #356 --- core/native/src/Instant.kt | 3 +++ core/native/src/LocalDate.kt | 3 +++ core/native/src/LocalDateTime.kt | 3 +++ core/native/src/LocalTime.kt | 3 +++ core/native/src/UtcOffset.kt | 3 +++ 5 files changed, 15 insertions(+) diff --git a/core/native/src/Instant.kt b/core/native/src/Instant.kt index 32474be45..70e0017be 100644 --- a/core/native/src/Instant.kt +++ b/core/native/src/Instant.kt @@ -143,6 +143,9 @@ public actual class Instant internal constructor(public actual val epochSeconds: throw DateTimeFormatException("Failed to parse an instant from '$input'", e) } + @Deprecated("This overload is only kept for binary compatibility", level = DeprecationLevel.HIDDEN) + public fun parse(isoString: String): Instant = parse(input = isoString) + public actual val DISTANT_PAST: Instant = fromEpochSeconds(DISTANT_PAST_SECONDS, 999_999_999) public actual val DISTANT_FUTURE: Instant = fromEpochSeconds(DISTANT_FUTURE_SECONDS, 0) diff --git a/core/native/src/LocalDate.kt b/core/native/src/LocalDate.kt index 3c53b949e..14ee3a173 100644 --- a/core/native/src/LocalDate.kt +++ b/core/native/src/LocalDate.kt @@ -44,6 +44,9 @@ public actual class LocalDate actual constructor(public actual val year: Int, pu public actual companion object { public actual fun parse(input: CharSequence, format: DateTimeFormat): LocalDate = format.parse(input) + @Deprecated("This overload is only kept for binary compatibility", level = DeprecationLevel.HIDDEN) + public fun parse(isoString: String): LocalDate = parse(input = isoString) + // org.threeten.bp.LocalDate#toEpochDay public actual fun fromEpochDays(epochDays: Int): LocalDate { // LocalDate(-999999, 1, 1).toEpochDay(), LocalDate(999999, 12, 31).toEpochDay() diff --git a/core/native/src/LocalDateTime.kt b/core/native/src/LocalDateTime.kt index c62ef1154..33187d4a5 100644 --- a/core/native/src/LocalDateTime.kt +++ b/core/native/src/LocalDateTime.kt @@ -20,6 +20,9 @@ public actual constructor(public actual val date: LocalDate, public actual val t public actual fun parse(input: CharSequence, format: DateTimeFormat): LocalDateTime = format.parse(input) + @Deprecated("This overload is only kept for binary compatibility", level = DeprecationLevel.HIDDEN) + public fun parse(isoString: String): LocalDateTime = parse(input = isoString) + internal actual val MIN: LocalDateTime = LocalDateTime(LocalDate.MIN, LocalTime.MIN) internal actual val MAX: LocalDateTime = LocalDateTime(LocalDate.MAX, LocalTime.MAX) diff --git a/core/native/src/LocalTime.kt b/core/native/src/LocalTime.kt index b22b34c77..28ebd78df 100644 --- a/core/native/src/LocalTime.kt +++ b/core/native/src/LocalTime.kt @@ -35,6 +35,9 @@ public actual class LocalTime actual constructor( public actual companion object { public actual fun parse(input: CharSequence, format: DateTimeFormat): LocalTime = format.parse(input) + @Deprecated("This overload is only kept for binary compatibility", level = DeprecationLevel.HIDDEN) + public fun parse(isoString: String): LocalTime = parse(input = isoString) + public actual fun fromSecondOfDay(secondOfDay: Int): LocalTime = ofSecondOfDay(secondOfDay, 0) diff --git a/core/native/src/UtcOffset.kt b/core/native/src/UtcOffset.kt index ea9e95d55..852ae62f4 100644 --- a/core/native/src/UtcOffset.kt +++ b/core/native/src/UtcOffset.kt @@ -24,6 +24,9 @@ public actual class UtcOffset private constructor(public actual val totalSeconds public actual fun parse(input: CharSequence, format: DateTimeFormat): UtcOffset = format.parse(input) + @Deprecated("This overload is only kept for binary compatibility", level = DeprecationLevel.HIDDEN) + public fun parse(offsetString: String): UtcOffset = parse(input = offsetString) + private fun validateTotal(totalSeconds: Int) { if (totalSeconds !in -18 * SECONDS_PER_HOUR .. 18 * SECONDS_PER_HOUR) { throw IllegalArgumentException("Total seconds value is out of range: $totalSeconds") From 5fdb4a9a871861ab98c898eb493096c8f2a23035 Mon Sep 17 00:00:00 2001 From: Dmitry Khalanskiy Date: Fri, 1 Mar 2024 13:54:24 +0100 Subject: [PATCH 2/2] Also restore ABI compatibility for JS and Wasm --- core/commonJs/src/Instant.kt | 3 +++ core/commonJs/src/LocalDate.kt | 3 +++ core/commonJs/src/LocalDateTime.kt | 3 +++ core/commonJs/src/LocalTime.kt | 3 +++ core/commonJs/src/UtcOffset.kt | 3 +++ 5 files changed, 15 insertions(+) diff --git a/core/commonJs/src/Instant.kt b/core/commonJs/src/Instant.kt index f15268615..cfbd3da2f 100644 --- a/core/commonJs/src/Instant.kt +++ b/core/commonJs/src/Instant.kt @@ -90,6 +90,9 @@ public actual class Instant internal constructor(internal val value: jtInstant) } } + @Deprecated("This overload is only kept for binary compatibility", level = DeprecationLevel.HIDDEN) + public fun parse(isoString: String): Instant = parse(input = isoString) + /** A workaround for the string representations of Instant that have an offset of the form * "+XX" not being recognized by [jtOffsetDateTime.parse], while "+XX:XX" work fine. */ private fun fixOffsetRepresentation(isoString: String): String { diff --git a/core/commonJs/src/LocalDate.kt b/core/commonJs/src/LocalDate.kt index 892490c9b..a650665d7 100644 --- a/core/commonJs/src/LocalDate.kt +++ b/core/commonJs/src/LocalDate.kt @@ -29,6 +29,9 @@ public actual class LocalDate internal constructor(internal val value: jtLocalDa format.parse(input) } + @Deprecated("This overload is only kept for binary compatibility", level = DeprecationLevel.HIDDEN) + public fun parse(isoString: String): LocalDate = parse(input = isoString) + internal actual val MIN: LocalDate = LocalDate(jtLocalDate.MIN) internal actual val MAX: LocalDate = LocalDate(jtLocalDate.MAX) diff --git a/core/commonJs/src/LocalDateTime.kt b/core/commonJs/src/LocalDateTime.kt index 2a7ea8dd4..c85e772a4 100644 --- a/core/commonJs/src/LocalDateTime.kt +++ b/core/commonJs/src/LocalDateTime.kt @@ -66,6 +66,9 @@ public actual class LocalDateTime internal constructor(internal val value: jtLoc format.parse(input) } + @Deprecated("This overload is only kept for binary compatibility", level = DeprecationLevel.HIDDEN) + public fun parse(isoString: String): LocalDateTime = parse(input = isoString) + internal actual val MIN: LocalDateTime = LocalDateTime(jtLocalDateTime.MIN) internal actual val MAX: LocalDateTime = LocalDateTime(jtLocalDateTime.MAX) diff --git a/core/commonJs/src/LocalTime.kt b/core/commonJs/src/LocalTime.kt index 3ed089ce2..674e5cb69 100644 --- a/core/commonJs/src/LocalTime.kt +++ b/core/commonJs/src/LocalTime.kt @@ -56,6 +56,9 @@ public actual class LocalTime internal constructor(internal val value: jtLocalTi format.parse(input) } + @Deprecated("This overload is only kept for binary compatibility", level = DeprecationLevel.HIDDEN) + public fun parse(isoString: String): LocalTime = parse(input = isoString) + public actual fun fromSecondOfDay(secondOfDay: Int): LocalTime = try { jsTry { jtLocalTime.ofSecondOfDay(secondOfDay, 0) }.let(::LocalTime) } catch (e: Throwable) { diff --git a/core/commonJs/src/UtcOffset.kt b/core/commonJs/src/UtcOffset.kt index 4c3458f22..335626be7 100644 --- a/core/commonJs/src/UtcOffset.kt +++ b/core/commonJs/src/UtcOffset.kt @@ -32,6 +32,9 @@ public actual class UtcOffset internal constructor(internal val zoneOffset: jtZo else -> format.parse(input) } + @Deprecated("This overload is only kept for binary compatibility", level = DeprecationLevel.HIDDEN) + public fun parse(offsetString: String): UtcOffset = parse(input = offsetString) + @Suppress("FunctionName") public actual fun Format(block: DateTimeFormatBuilder.WithUtcOffset.() -> Unit): DateTimeFormat = UtcOffsetFormat.build(block)