Open nesk opened 2 months ago
ZERO
is okay is there are some use cases for it, but isNegative
and isPositive
don't make sense for DateTimePeriod
because of periods like 1 month - 30 days
. If you add this period to 2024-01-01
you'll get a later date, and if you add it to 2024-02-01
, you'll get an earlier date:
val date1 = LocalDate(2024, 1, 1)
val date2 = LocalDate(2024, 2, 1)
val period = DatePeriod(months = 1, days = -30)
println(date1 < date1 + period) // true
println(date2 < date2 + period) // false
(https://pl.kotl.in/oTONoY3XP)
Do you know of any use cases for ZERO
?
I can see your point for negative/positive, I understand.
ZERO
would be mainly used for verifications. I've just done a subtraction two dates, is it equal to zero or no?
Can't one write date1 == date2
instead of date1 - date2 == ZERO
?
The
Duration
class in the standard library provides everything you need to analyze its state:isNegative
isPositive
ZERO
instanceThose things are missing in the
DateTimePeriod
class.Would you consider adding those features?