Skip to content

Commit b1a0dd7

Browse files
committed
Address the review
1 parent 1066bce commit b1a0dd7

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

core/common/src/DateTimePeriod.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import kotlinx.datetime.serializers.DateTimePeriodComponentSerializer
1313
import kotlin.math.*
1414
import kotlin.time.Duration
1515
import kotlinx.serialization.Serializable
16-
import kotlin.text.toLong
1716

1817
/**
1918
* A difference between two [instants][Instant], decomposed into date and time components.

core/common/src/LocalDate.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,8 +365,6 @@ public expect fun LocalDate.periodUntil(other: LocalDate): DatePeriod
365365
* - Positive or zero if this date is later than the other.
366366
* - Exactly zero if this date is equal to the other.
367367
*
368-
* @throws DateTimeArithmeticException if the number of months between the two dates exceeds an Int.
369-
*
370368
* @see LocalDate.periodUntil for the same operation with the order of arguments reversed.
371369
* @sample kotlinx.datetime.test.samples.LocalDateSamples.minusDate
372370
*/

core/jvm/src/LocalDate.kt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ public actual class LocalDate internal constructor(internal val value: jtLocalDa
8484
actual override fun compareTo(other: LocalDate): Int = this.value.compareTo(other.value)
8585

8686
public actual fun toEpochDays(): Long = value.toEpochDay()
87+
88+
@PublishedApi
89+
@Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER")
90+
@LowPriorityInOverloadResolution
91+
internal fun toEpochDays(): Int = value.toEpochDay().clampToInt()
8792
}
8893

8994
@Deprecated("Use the plus overload with an explicit number of units", ReplaceWith("this.plus(1, unit)"))
@@ -150,6 +155,12 @@ public actual fun LocalDate.until(other: LocalDate, unit: DateTimeUnit.DateBased
150155
is DateTimeUnit.DayBased -> (this.value.until(other.value, ChronoUnit.DAYS) / unit.days)
151156
}
152157

158+
@PublishedApi
159+
@Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER")
160+
@LowPriorityInOverloadResolution
161+
internal fun LocalDate.until(other: LocalDate, unit: DateTimeUnit.DateBased): Int =
162+
until(other, unit).clampToInt()
163+
153164
public actual fun LocalDate.daysUntil(other: LocalDate): Int =
154165
this.value.until(other.value, ChronoUnit.DAYS).clampToInt()
155166

0 commit comments

Comments
 (0)