Skip to content

Commit f77c2a0

Browse files
committed
Fix a test
1 parent ece4e11 commit f77c2a0

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

core/commonKotlin/src/Instant.kt

+5-2
Original file line numberDiff line numberDiff line change
@@ -282,8 +282,11 @@ internal fun parseIso(isoString: String): Instant {
282282
++i
283283
}
284284
val year = when {
285-
i > yearStart + 9 -> {
286-
parseFailure("Expected at most 9 digits for the year number, got ${i - yearStart}")
285+
i > yearStart + 10 -> {
286+
parseFailure("Expected at most 10 digits for the year number, got ${i - yearStart}")
287+
}
288+
i == yearStart + 10 && s[yearStart] >= '2' -> {
289+
parseFailure("Expected at most 9 digits for the year number or year 1000000000, got ${i - yearStart}")
287290
}
288291
i - yearStart < 4 -> {
289292
parseFailure("The year number must be padded to 4 digits, got ${i - yearStart} digits")

core/commonKotlin/test/InstantIsoStringsTest.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ class InstantIsoStringsTest {
372372
Instant.DISTANT_FUTURE,
373373
Instant.DISTANT_PAST,
374374
Instant.fromEpochSeconds(0, 0),
375-
Instant.parse("2020-01-02T03:04:05.6789Z"),
375+
parseInstant("2020-01-02T03:04:05.6789Z"),
376376
Instant.MAX,
377377
Instant.MIN,
378378
)
@@ -392,7 +392,7 @@ class InstantIsoStringsTest {
392392
if (instant == Instant.MAX && offsetSeconds < 0 ||
393393
instant == Instant.MIN && offsetSeconds > 0
394394
) continue
395-
val newInstant = Instant.parse("${instant.toString().dropLast(1)}$offsetString")
395+
val newInstant = parseInstant("${instant.toString().dropLast(1)}$offsetString")
396396
assertEquals(newInstant, instant.minus(offsetSeconds.seconds))
397397
}
398398
}

0 commit comments

Comments
 (0)