kotest-assertions-core / io.kotest.matchers.date / java.time.OffsetDateTime / shouldNotHaveSameDayAs

shouldNotHaveSameDayAs

infix fun OffsetDateTime.shouldNotHaveSameDayAs(date: OffsetDateTime): Unit

Asserts that this day is NOT the same as date's day

Verifies that this day isn't the same as date's day, ignoring any other fields. For example, 09/02/1998 10:00:00 -03:00 doesn't have the same day as 10/02/1998 10:00:00 -03:00, and this assertion should pass for this comparison

Opposite of OffsetDateTime.shouldHaveSameDayAs

    val firstDate = OffsetDateTime.of(1998, 2, 9, 10, 0, 0, 0, ZoneOffset.ofHours(-3))
    val secondDate = OffsetDateTime.of(1998, 2, 10, 19, 0, 0, 0, ZoneOffset.ofHours(-3))

    firstDate shouldNotHaveSameDayAs secondDate    // Assertion passes


    val firstDate = OffsetDateTime.of(1998, 2, 9, 10, 0, 0, 0, ZoneOffset.ofHours(-3))
    val secondDate = OffsetDateTime.of(2018, 3, 9, 1, 30, 30, 30, ZoneOffset.ofHours(-5))

    firstDate shouldNotHaveSameDayAs  secondDate   // Assertion fails, 9 == 9, and we expected a difference