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

shouldNotHaveSameMonthAs

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

Opposite of ZonedDateTime.shouldHaveSameMonthAs

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

    firstDate shouldHaveSameMonthAs secondDate   //  Assertion passes


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

    firstDate shouldHaveSameMonthAs secondDate   //  Assertion fails, 2 != 3