Skip to content

Commit dc65792

Browse files
committed
Update JVM Instant min/max values to be equal to Native's
1 parent 5e3d785 commit dc65792

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

runtime/runtime-core/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ kotlin {
2222
implementation(libs.okio)
2323
// Coroutines' locking features are used in retry token bucket implementations
2424
api(libs.kotlinx.coroutines.core)
25+
implementation(libs.kotlinx.datetime)
2526
}
2627
}
2728

2829
nativeMain {
2930
dependencies {
3031
api(libs.crt.kotlin)
31-
implementation(libs.kotlinx.datetime)
3232
}
3333
}
3434

runtime/runtime-core/jvm/src/aws/smithy/kotlin/runtime/time/InstantJVM.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import kotlin.time.Duration
2525
import kotlin.time.toKotlinDuration
2626
import java.time.Duration as jtDuration
2727
import java.time.Instant as jtInstant
28+
import kotlinx.datetime.Instant as KtInstant
2829

2930
// FIXME Consider making this multiplatform (`common`) using kotlinx.datetime
3031
public actual class Instant(internal val value: jtInstant) : Comparable<Instant> {
@@ -136,12 +137,12 @@ public actual class Instant(internal val value: jtInstant) : Comparable<Instant>
136137
/**
137138
* Create an [Instant] with the minimum possible value
138139
*/
139-
public actual val MIN_VALUE: Instant = Instant(jtInstant.MIN)
140+
public actual val MIN_VALUE: Instant = fromEpochMilliseconds(KtInstant.DISTANT_PAST.toEpochMilliseconds())
140141

141142
/**
142143
* Create an [Instant] with the maximum possible value
143144
*/
144-
public actual val MAX_VALUE: Instant = Instant(jtInstant.MAX)
145+
public actual val MAX_VALUE: Instant = fromEpochMilliseconds(KtInstant.DISTANT_FUTURE.toEpochMilliseconds())
145146
}
146147
}
147148

runtime/serde/serde-cbor/common/test/aws/smithy/kotlin/runtime/serde/cbor/CborSerializerTest.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ class CborSerializerTest {
278278
Instant.now() + 10.days,
279279
Instant.now() + 365.days,
280280
Instant.now() + 1825.days,
281+
Instant.MAX_VALUE,
281282
)
282283

283284
val serializer = CborSerializer()

0 commit comments

Comments
 (0)