Skip to content

Commit

Permalink
Deprecate DatePeriod.plus and DateTimePeriod.plus
Browse files Browse the repository at this point in the history
Fixes #381
  • Loading branch information
dkhalanskyjb committed Oct 18, 2024
1 parent 670a914 commit 2db494c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions core/common/src/DateTimePeriod.kt
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,10 @@ public fun Duration.toDateTimePeriod(): DateTimePeriod = buildDateTimePeriod(tot
*
* @throws DateTimeArithmeticException if arithmetic overflow happens.
*/
@Deprecated(
"Adding periods is not a well-defined operation. See https://github.com/Kotlin/kotlinx-datetime/issues/381",
level = DeprecationLevel.ERROR
)
public operator fun DateTimePeriod.plus(other: DateTimePeriod): DateTimePeriod = buildDateTimePeriod(
safeAdd(totalMonths, other.totalMonths),
safeAdd(days, other.days),
Expand All @@ -591,6 +595,10 @@ public operator fun DateTimePeriod.plus(other: DateTimePeriod): DateTimePeriod =
*
* @throws DateTimeArithmeticException if arithmetic overflow happens.
*/
@Deprecated(
"Adding periods is not a well-defined operation. See https://github.com/Kotlin/kotlinx-datetime/issues/381",
level = DeprecationLevel.ERROR
)
public operator fun DatePeriod.plus(other: DatePeriod): DatePeriod = DatePeriod(
safeAdd(totalMonths, other.totalMonths),
safeAdd(days, other.days),
Expand Down

0 comments on commit 2db494c

Please sign in to comment.