Paul Woitaschek
01/25/2021, 5:45 PMloopDate.plus(DateTimeUnit.DateBased.DayBased(fastingDays.size))
Now this throws:
java.lang.IllegalArgumentException: Unit duration must be positive, but was 0 days.
at kotlinx.datetime.DateTimeUnit$DateBased$DayBased.<init>(DateTimeUnit.kt:68)
Instead I would prefer to have the function just return the initial date instead of throwing when adding 0 dates.
Now we always need to write != 0 checks everywhere and use the initial instanceMarc Knaup
01/25/2021, 6:38 PMDateTimeUnit.DateBased.DayBased
is supposed to be used 🤔
Use one of those:
.plus(0, DateTimeUnit.DAY)
.plus(DatePeriod(days = 0))
Paul Woitaschek
01/25/2021, 7:05 PMpublic actual fun LocalDate.plus(unit: DateTimeUnit.DateBased): LocalDate = plusNumber(1, unit)
DateTimeUnit.DayBased(x)