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

shouldNotHaveSameMonthAs

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

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

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

Opposite of OffsetDateTime.shouldHaveSameMonthAs

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

    firstDate shouldNotHaveSameMonthAs secondDate    //  Assertion passes


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

    firstDate shouldNotHaveSameMonthAs  secondDate   //  Assertion fails, 2 == 2, and we expected a difference