Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore the broken bit of ABI compatibility for Native, JS, and Wasm #357

Merged
merged 2 commits into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions core/commonJs/src/Instant.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 3 additions & 0 deletions core/commonJs/src/LocalDate.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
3 changes: 3 additions & 0 deletions core/commonJs/src/LocalDateTime.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
3 changes: 3 additions & 0 deletions core/commonJs/src/LocalTime.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
3 changes: 3 additions & 0 deletions core/commonJs/src/UtcOffset.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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<UtcOffset> =
UtcOffsetFormat.build(block)
Expand Down
3 changes: 3 additions & 0 deletions core/native/src/Instant.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions core/native/src/LocalDate.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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>): 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()
Expand Down
3 changes: 3 additions & 0 deletions core/native/src/LocalDateTime.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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>): 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)

Expand Down
3 changes: 3 additions & 0 deletions core/native/src/LocalTime.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ public actual class LocalTime actual constructor(
public actual companion object {
public actual fun parse(input: CharSequence, format: DateTimeFormat<LocalTime>): 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)

Expand Down
3 changes: 3 additions & 0 deletions core/native/src/UtcOffset.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ public actual class UtcOffset private constructor(public actual val totalSeconds

public actual fun parse(input: CharSequence, format: DateTimeFormat<UtcOffset>): 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")
Expand Down