Skip to content

Commit

Permalink
Remove unused functions
Browse files Browse the repository at this point in the history
  • Loading branch information
dkhalanskyjb committed Mar 22, 2024
1 parent b07ef03 commit 1e5668c
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 22 deletions.
11 changes: 0 additions & 11 deletions core/commonJs/src/Instant.kt
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,6 @@ 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 {
val time = isoString.indexOf('T', ignoreCase = true)
if (time == -1) return isoString // the string is malformed
val offset = isoString.indexOfLast { c -> c == '+' || c == '-' }
if (offset < time) return isoString // the offset is 'Z' and not +/- something else
val separator = isoString.indexOf(':', offset) // if there is a ':' in the offset, no changes needed
return if (separator != -1) isoString else "$isoString:00"
}

public actual fun fromEpochSeconds(epochSeconds: Long, nanosecondAdjustment: Long): Instant = try {
/* Performing normalization here because otherwise this fails:
assertEquals((Long.MAX_VALUE % 1_000_000_000).toInt(),
Expand Down
11 changes: 0 additions & 11 deletions core/jvm/src/Instant.kt
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,6 @@ 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 a quirk of the JDKs older than 11 where the string representations of Instant that have an
* offset of the form "+XX" are not recognized by [jtOffsetDateTime.parse], while "+XX:XX" work fine. */
private fun fixOffsetRepresentation(isoString: CharSequence): CharSequence {
val time = isoString.indexOf('T', ignoreCase = true)
if (time == -1) return isoString // the string is malformed
val offset = isoString.indexOfLast { c -> c == '+' || c == '-' }
if (offset < time) return isoString // the offset is 'Z' and not +/- something else
val separator = isoString.indexOf(':', offset) // if there is a ':' in the offset, no changes needed
return if (separator != -1) isoString else "$isoString:00"
}

public actual fun fromEpochSeconds(epochSeconds: Long, nanosecondAdjustment: Long): Instant = try {
Instant(jtInstant.ofEpochSecond(epochSeconds, nanosecondAdjustment))
} catch (e: Exception) {
Expand Down

0 comments on commit 1e5668c

Please sign in to comment.