Skip to content

Broken guarantee in Instant.periodUntil #484

Open
@dkhalanskyjb

Description

@dkhalanskyjb

Quoting https://kotlinlang.org/api/kotlinx-datetime/kotlinx-datetime/kotlinx.datetime/period-until.html:

All components of the DateTimePeriod returned are [...] positive or zero if this instant is earlier than the other.

val tz = TimeZone.of("Europe/Berlin")
println(
    LocalDateTime(2025, 3, 29, 2, 30).toInstant(tz).periodUntil(
    LocalDateTime(2025, 3, 30, 3, 10).toInstant(tz), tz))
// P1DT-20M

Runnable: https://pl.kotl.in/LedZ6Njqf

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions