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

shouldNotHaveSameDayAs

infix fun ZonedDateTime.shouldNotHaveSameDayAs(date: ZonedDateTime): 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 America/Sao_Paulo doesn't have the same day as 10/02/1998 10:00:00 -03:00 America/Sao_Paulo, and this assertion should pass for this comparison

Opposite of ZonedDateTime.shouldHaveSameDayAs

    val firstDate = ZonedDateTime.of(1998, 2, 9, 10, 0, 0, 0, ZoneId.of("America/Sao_Paulo"))
    val secondDate = ZonedDateTime.of(1998, 2, 10, 10, 0, 0, 0, ZoneId.of("America/Sao_Paulo"))

    firstDate shouldNotHaveSameDayAs secondDate    // Assertion passes


    val firstDate = ZonedDateTime.of(1998, 2, 9, 10, 0, 0, 0, ZoneId.of("America/Sao_Paulo"))
    val secondDate = ZonedDateTime.of(2018, 3, 9, 11, 30, 30, 30, ZoneId.of("America/Chicago"))

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