Closed nesk closed 2 months ago
Please read https://github.com/Kotlin/kotlinx-datetime?tab=readme-ov-file#date--time-arithmetic
If you have some specific code that needs LocalTime
arithmetics, please share it here or on the Kotlin Slack, and we'll help you reach an idiomatic and robust solution.
Sorry, I did not see this section in the documentation 😓
Seems fine to me, I will use Instant
for arithmetics!
The
Instant
type supports addition and subtraction of aDuration
:The
LocalDate
type supports addition and subtraction ofDatePeriod
:However, the
LocalTime
doesn't support any addition or subtraction, which requires cumbersome code to do these changes:What about adding a
TimePeriod
type? This would allow to write code like this:This would also pave the way for addition and subtraction of the
LocalDateTime
type: