Skip to content

Commit 3247cbf

Browse files
committed
Address the review
1 parent d52f0cb commit 3247cbf

File tree

4 files changed

+14
-13
lines changed

4 files changed

+14
-13
lines changed

core/common/src/DateTimePeriod.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ public class DatePeriod internal constructor(
465465

466466
/** The number of nanoseconds in this period. Always equal to zero. */
467467
override val nanoseconds: Int get() = 0
468-
override val totalNanoseconds: Long get() = 0
468+
internal override val totalNanoseconds: Long get() = 0
469469

470470
public companion object {
471471
/**
@@ -495,9 +495,9 @@ public class DatePeriod internal constructor(
495495
public fun String.toDatePeriod(): DatePeriod = DatePeriod.parse(this)
496496

497497
private class DateTimePeriodImpl(
498-
override val totalMonths: Long,
498+
internal override val totalMonths: Long,
499499
override val days: Int,
500-
override val totalNanoseconds: Long,
500+
internal override val totalNanoseconds: Long,
501501
) : DateTimePeriod()
502502

503503
private fun totalMonths(years: Int, months: Int): Long = (years.toLong() * 12 + months.toLong()).also {

core/common/src/LocalDate.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import kotlinx.serialization.Serializable
2020
* is `2020-08-31` everywhere): see various [LocalDate.plus] and [LocalDate.minus] functions, as well
2121
* as [LocalDate.periodUntil] and various other [*until][LocalDate.daysUntil] functions.
2222
*
23-
* The range of supported years is at least is enough to represent dates of all instants between
23+
* The range of supported years is at least enough to represent dates of all instants between
2424
* [Instant.DISTANT_PAST] and [Instant.DISTANT_FUTURE].
2525
*
2626
* ### Arithmetic operations
@@ -168,7 +168,7 @@ public expect class LocalDate : Comparable<LocalDate> {
168168
* The components [monthNumber] and [dayOfMonth] are 1-based.
169169
*
170170
* The supported ranges of components:
171-
* - [year] the range is at least is enough to represent dates of all instants between
171+
* - [year] the range is at least enough to represent dates of all instants between
172172
* [Instant.DISTANT_PAST] and [Instant.DISTANT_FUTURE]
173173
* - [monthNumber] `1..12`
174174
* - [dayOfMonth] `1..31`, the upper bound can be less, depending on the month

core/common/test/InstantTest.kt

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -313,9 +313,7 @@ class InstantTest {
313313
val diff2 = date1.periodUntil(date2)
314314

315315
if (diff1 != diff2)
316-
throw AssertionError(
317-
"start: $instant1, end: $instant2, diff by instants: $diff1, diff by dates: $diff2"
318-
)
316+
fail("start: $instant1, end: $instant2, diff by instants: $diff1, diff by dates: $diff2")
319317
}
320318
}
321319
}
@@ -560,10 +558,13 @@ class InstantRangeTest {
560558
assertArithmeticFails("$instant") { instant.plus(Long.MIN_VALUE, DateTimeUnit.YEAR, UTC) }
561559
}
562560
for (instant in smallInstants) {
563-
instant.plus(2 * Int.MAX_VALUE.toLong(), DateTimeUnit.DAY, UTC)
564-
instant.plus(2 * Int.MIN_VALUE.toLong(), DateTimeUnit.DAY, UTC)
565-
instant.plus(2 * Int.MAX_VALUE.toLong(), DateTimeUnit.MONTH, UTC)
566-
instant.plus(2 * Int.MIN_VALUE.toLong(), DateTimeUnit.MONTH, UTC)
561+
fun roundTrip(value: Long, unit: DateTimeUnit) {
562+
assertEquals(instant, instant.plus(value, unit, UTC).minus(value, unit, UTC))
563+
}
564+
roundTrip(2L * Int.MAX_VALUE, DateTimeUnit.DAY)
565+
roundTrip(2L * Int.MIN_VALUE, DateTimeUnit.DAY)
566+
roundTrip(2L * Int.MAX_VALUE, DateTimeUnit.MONTH)
567+
roundTrip(2L * Int.MIN_VALUE, DateTimeUnit.MONTH)
567568
}
568569
// Overflowing a LocalDateTime in input
569570
maxValidInstant.plus(-1, DateTimeUnit.NANOSECOND, UTC)

settings.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@ project(":timezones/full").name = "kotlinx-datetime-zoneinfo"
2121
include(":serialization")
2222
project(":serialization").name = "kotlinx-datetime-serialization"
2323
include(":js-without-timezones")
24-
project(":js-without-timezones").name = "kotlinx-datetime-js-without-timezones"
24+
project(":js-without-timezones").name = "kotlinx-datetime-js-test-without-timezones"
2525
include(":benchmarks")

0 commit comments

Comments
 (0)