Skip to content

Commit a962bde

Browse files
committed
Add unary minus operator to DatePeriod and DateTimePeriod
1 parent ac5ec5f commit a962bde

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

core/common/src/DateTimePeriod.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,8 @@ public operator fun DateTimePeriod.minus(other: DateTimePeriod) : DateTimePeriod
459459
safeAdd(totalNanoseconds, -other.totalNanoseconds)
460460
)
461461

462+
public operator fun DateTimePeriod.unaryMinus(): DateTimePeriod = buildDateTimePeriod(-totalMonths, -days, -totalNanoseconds)
463+
462464
/**
463465
* Adds two [DatePeriod] instances.
464466
*
@@ -478,3 +480,5 @@ public operator fun DatePeriod.minus(other: DatePeriod): DatePeriod = DatePeriod
478480
safeAdd(totalMonths, -other.totalMonths),
479481
safeAdd(days, -other.days)
480482
)
483+
484+
public operator fun DatePeriod.unaryMinus(): DatePeriod = DatePeriod(-totalMonths, -days)

0 commit comments

Comments
 (0)