How to use ZonedDateTime.atSameZone method of io.kotest.matchers.date.zoneddatetime class

Best Kotest code snippet using io.kotest.matchers.date.zoneddatetime.ZonedDateTime.atSameZone

DateMatchersTest.kt

Source:DateMatchersTest.kt Github

copy

Full Screen

1package com.sksamuel.kotest.matchers.date2import io.kotest.assertions.shouldFail3import io.kotest.assertions.throwables.shouldThrow4import io.kotest.core.spec.style.StringSpec5import io.kotest.matchers.date.after6import io.kotest.matchers.date.atSameZone7import io.kotest.matchers.date.before8import io.kotest.matchers.date.haveSameDay9import io.kotest.matchers.date.haveSameHours10import io.kotest.matchers.date.haveSameInstantAs11import io.kotest.matchers.date.haveSameMinutes12import io.kotest.matchers.date.haveSameMonth13import io.kotest.matchers.date.haveSameNanos14import io.kotest.matchers.date.haveSameSeconds15import io.kotest.matchers.date.haveSameYear16import io.kotest.matchers.date.shouldBeAfter17import io.kotest.matchers.date.shouldBeBefore18import io.kotest.matchers.date.shouldBeBetween19import io.kotest.matchers.date.shouldBeToday20import io.kotest.matchers.date.shouldBeWithin21import io.kotest.matchers.date.shouldHaveDayOfMonth22import io.kotest.matchers.date.shouldHaveDayOfWeek23import io.kotest.matchers.date.shouldHaveDayOfYear24import io.kotest.matchers.date.shouldHaveHour25import io.kotest.matchers.date.shouldHaveMinute26import io.kotest.matchers.date.shouldHaveMonth27import io.kotest.matchers.date.shouldHaveNano28import io.kotest.matchers.date.shouldHaveSameDayAs29import io.kotest.matchers.date.shouldHaveSameHoursAs30import io.kotest.matchers.date.shouldHaveSameInstantAs31import io.kotest.matchers.date.shouldHaveSameMinutesAs32import io.kotest.matchers.date.shouldHaveSameMonthAs33import io.kotest.matchers.date.shouldHaveSameNanosAs34import io.kotest.matchers.date.shouldHaveSameSecondsAs35import io.kotest.matchers.date.shouldHaveSameYearAs36import io.kotest.matchers.date.shouldHaveSecond37import io.kotest.matchers.date.shouldNotBeAfter38import io.kotest.matchers.date.shouldNotBeBefore39import io.kotest.matchers.date.shouldNotBeBetween40import io.kotest.matchers.date.shouldNotBeToday41import io.kotest.matchers.date.shouldNotBeWithin42import io.kotest.matchers.date.shouldNotHaveSameDayAs43import io.kotest.matchers.date.shouldNotHaveSameHoursAs44import io.kotest.matchers.date.shouldNotHaveSameInstantAs45import io.kotest.matchers.date.shouldNotHaveSameMinutesAs46import io.kotest.matchers.date.shouldNotHaveSameMonthAs47import io.kotest.matchers.date.shouldNotHaveSameNanosAs48import io.kotest.matchers.date.shouldNotHaveSameSecondsAs49import io.kotest.matchers.date.shouldNotHaveSameYearAs50import io.kotest.matchers.date.within51import io.kotest.matchers.shouldBe52import io.kotest.matchers.should53import io.kotest.matchers.shouldNot54import io.kotest.matchers.shouldNotBe55import java.time.DayOfWeek.SATURDAY56import java.time.Duration57import java.time.LocalDate58import java.time.LocalDateTime59import java.time.LocalTime60import java.time.Month61import java.time.OffsetDateTime62import java.time.Period63import java.time.ZoneId64import java.time.ZoneOffset65import java.time.ZonedDateTime66class DateMatchersTest : StringSpec() {67 init {68 "LocalTime should have same nanos ignoring other fields" {69 LocalTime.of(1, 2, 3, 4) should haveSameNanos(LocalTime.of(5, 6, 7, 4))70 LocalTime.of(1, 2, 3, 4) shouldNot haveSameNanos(LocalTime.of(1, 2, 3, 8))71 LocalTime.of(1, 2, 3, 4).shouldHaveSameNanosAs(LocalTime.of(5, 6, 7, 4))72 LocalTime.of(1, 2, 3, 4).shouldNotHaveSameNanosAs(LocalTime.of(1, 2, 3, 8))73 }74 "LocalTime should have same seconds ignoring other fields" {75 LocalTime.of(1, 2, 3, 4) should haveSameSeconds(LocalTime.of(5, 6, 3, 4))76 LocalTime.of(1, 2, 3, 4) shouldNot haveSameSeconds(LocalTime.of(1, 2, 5, 4))77 LocalTime.of(1, 2, 3, 4).shouldHaveSameSecondsAs(LocalTime.of(5, 6, 3, 4))78 LocalTime.of(1, 2, 3, 4).shouldNotHaveSameSecondsAs(LocalTime.of(1, 2, 5, 4))79 }80 "LocalTime should have same minutes ignoring other fields" {81 LocalTime.of(1, 2, 3, 4) should haveSameMinutes(LocalTime.of(5, 2, 7, 8))82 LocalTime.of(1, 2, 3, 4) shouldNot haveSameMinutes(LocalTime.of(1, 5, 3, 4))83 LocalTime.of(1, 2, 3, 4).shouldHaveSameMinutesAs(LocalTime.of(5, 2, 7, 8))84 LocalTime.of(1, 2, 3, 4).shouldNotHaveSameMinutesAs(LocalTime.of(1, 5, 3, 4))85 }86 "LocalTime should have same hours ignoring other fields" {87 LocalTime.of(12, 1, 2, 7777) should haveSameHours(LocalTime.of(12, 59, 58, 9999))88 LocalTime.of(3, 59, 58, 9999) shouldNot haveSameHours(LocalTime.of(12, 59, 58, 9999))89 LocalTime.of(12, 1, 2, 7777).shouldHaveSameHoursAs(LocalTime.of(12, 59, 58, 9999))90 LocalTime.of(3, 59, 58, 9999).shouldNotHaveSameHoursAs(LocalTime.of(12, 59, 58, 9999))91 }92 "LocalDate should have same year ignoring other fields" {93 LocalDate.of(2014, 1, 2) should haveSameYear(LocalDate.of(2014, 5, 6))94 LocalDate.of(2014, 1, 2) shouldNot haveSameYear(LocalDate.of(2018, 5, 6))95 LocalDate.of(2014, 1, 2).shouldHaveSameYearAs(LocalDate.of(2014, 5, 6))96 LocalDate.of(2014, 1, 2).shouldNotHaveSameYearAs(LocalDate.of(2018, 5, 6))97 }98 "LocalDateTime should have same year ignoring other fields" {99 LocalDateTime.of(2014, 1, 2, 4, 3, 2) should haveSameYear(LocalDateTime.of(2014, 5, 6, 3, 2, 1))100 LocalDateTime.of(2014, 1, 2, 3, 2, 1) shouldNot haveSameYear(LocalDateTime.of(2018, 5, 6, 3, 2, 1))101 LocalDateTime.of(2014, 1, 2, 4, 3, 2).shouldHaveSameYearAs(LocalDateTime.of(2014, 5, 6, 3, 2, 1))102 LocalDateTime.of(2014, 1, 2, 3, 2, 1).shouldNotHaveSameYearAs(LocalDateTime.of(2018, 5, 6, 3, 2, 1))103 }104 "ZonedDateTime should have same year ignoring other fields" {105 LocalDateTime.of(2014, 1, 2, 4, 3, 2).atZone(ZoneId.of("Z")) should haveSameYear(LocalDateTime.of(2014, 5, 6, 3, 2, 1).atZone(ZoneId.of("Z")))106 LocalDateTime.of(2014, 1, 2, 3, 2, 1).atZone(ZoneId.of("Z")) shouldNot haveSameYear(LocalDateTime.of(2018, 5, 6, 3, 2, 1).atZone(ZoneId.of("Z")))107 LocalDateTime.of(2014, 1, 2, 4, 3, 2).atZone(ZoneId.of("Z")).shouldHaveSameYearAs(LocalDateTime.of(2014, 5, 6, 3, 2, 1).atZone(ZoneId.of("Z")))108 LocalDateTime.of(2014, 1, 2, 3, 2, 1).atZone(ZoneId.of("Z")).shouldNotHaveSameYearAs(LocalDateTime.of(2018, 5, 6, 3, 2, 1).atZone(ZoneId.of("Z")))109 }110 "OffsetDateTime should have same year ignoring other fields" {111 LocalDateTime.of(2014, 1, 2, 4, 3, 2).atOffset(ZoneOffset.UTC) should haveSameYear(LocalDateTime.of(2014, 5, 6, 3, 2, 1).atOffset(ZoneOffset.UTC))112 LocalDateTime.of(2014, 1, 2, 3, 2, 1).atOffset(ZoneOffset.UTC) shouldNot haveSameYear(LocalDateTime.of(2018, 5, 6, 3, 2, 1).atOffset(ZoneOffset.UTC))113 LocalDateTime.of(2014, 1, 2, 4, 3, 2).atOffset(ZoneOffset.UTC).shouldHaveSameYearAs(LocalDateTime.of(2014, 5, 6, 3, 2, 1).atOffset(ZoneOffset.UTC))114 LocalDateTime.of(2014, 1, 2, 3, 2, 1).atOffset(ZoneOffset.UTC).shouldNotHaveSameYearAs(LocalDateTime.of(2018, 5, 6, 3, 2, 1).atOffset(ZoneOffset.UTC))115 }116 "LocalDate should have same month ignoring other fields" {117 LocalDate.of(2014, 1, 2) should haveSameMonth(LocalDate.of(2016, 1, 6))118 LocalDate.of(2014, 1, 2) shouldNot haveSameMonth(LocalDate.of(2018, 4, 6))119 LocalDate.of(2014, 1, 2).shouldHaveSameMonthAs(LocalDate.of(2016, 1, 6))120 LocalDate.of(2014, 1, 2).shouldNotHaveSameMonthAs(LocalDate.of(2018, 4, 6))121 }122 "LocalDateTime should have same month ignoring other fields" {123 LocalDateTime.of(2014, 1, 2, 4, 3, 2) should haveSameMonth(LocalDateTime.of(2014, 1, 6, 3, 2, 1))124 LocalDateTime.of(2014, 1, 2, 3, 2, 1) shouldNot haveSameMonth(LocalDateTime.of(2018, 2, 6, 3, 2, 1))125 LocalDateTime.of(2014, 1, 2, 4, 3, 2).shouldHaveSameMonthAs(LocalDateTime.of(2014, 1, 6, 3, 2, 1))126 LocalDateTime.of(2014, 1, 2, 3, 2, 1).shouldNotHaveSameMonthAs(LocalDateTime.of(2018, 2, 6, 3, 2, 1))127 }128 "ZonedDateTime should have same month ignoring other fields" {129 LocalDateTime.of(2014, 1, 2, 4, 3, 2).atZone(ZoneId.of("Z")) should haveSameMonth(LocalDateTime.of(2014, 1, 6, 3, 2, 1).atZone(ZoneId.of("Z")))130 LocalDateTime.of(2014, 1, 2, 3, 2, 1).atZone(ZoneId.of("Z")) shouldNot haveSameMonth(LocalDateTime.of(2018, 2, 6, 3, 2, 1).atZone(ZoneId.of("Z")))131 LocalDateTime.of(2014, 1, 2, 4, 3, 2).atZone(ZoneId.of("Z")).shouldHaveSameMonthAs(LocalDateTime.of(2014, 1, 6, 3, 2, 1).atZone(ZoneId.of("Z")))132 LocalDateTime.of(2014, 1, 2, 3, 2, 1).atZone(ZoneId.of("Z")).shouldNotHaveSameMonthAs(LocalDateTime.of(2018, 2, 6, 3, 2, 1).atZone(ZoneId.of("Z")))133 }134 "OffsetDateTime should have same month ignoring other fields" {135 LocalDateTime.of(2014, 1, 2, 4, 3, 2).atOffset(ZoneOffset.UTC) should haveSameMonth(LocalDateTime.of(2014, 1, 6, 3, 2, 1).atOffset(ZoneOffset.UTC))136 LocalDateTime.of(2014, 1, 2, 3, 2, 1).atOffset(ZoneOffset.UTC) shouldNot haveSameMonth(LocalDateTime.of(2018, 2, 6, 3, 2, 1).atOffset(ZoneOffset.UTC))137 LocalDateTime.of(2014, 1, 2, 4, 3, 2).atOffset(ZoneOffset.UTC).shouldHaveSameMonthAs(LocalDateTime.of(2014, 1, 6, 3, 2, 1).atOffset(ZoneOffset.UTC))138 LocalDateTime.of(2014, 1, 2, 3, 2, 1).atOffset(ZoneOffset.UTC).shouldNotHaveSameMonthAs(LocalDateTime.of(2018, 2, 6, 3, 2, 1).atOffset(ZoneOffset.UTC))139 }140 "LocalDate should have same day ignoring other fields" {141 LocalDate.of(2014, 1, 2) should haveSameDay(LocalDate.of(2014, 1, 2))142 LocalDate.of(2014, 1, 2) shouldNot haveSameDay(LocalDate.of(2014, 4, 6))143 LocalDate.of(2014, 1, 2).shouldHaveSameDayAs(LocalDate.of(2014, 1, 2))144 LocalDate.of(2014, 1, 2).shouldNotHaveSameDayAs(LocalDate.of(2014, 4, 6))145 }146 "LocalDateTime should have same day ignoring other fields" {147 LocalDateTime.of(2014, 1, 2, 4, 3, 2) should haveSameDay(LocalDateTime.of(2014, 1, 2, 3, 2, 1))148 LocalDateTime.of(2014, 1, 2, 3, 2, 1) shouldNot haveSameDay(LocalDateTime.of(2014, 2, 6, 3, 2, 1))149 LocalDateTime.of(2014, 1, 2, 4, 3, 2).shouldHaveSameDayAs(LocalDateTime.of(2014, 1, 2, 3, 2, 1))150 LocalDateTime.of(2014, 1, 2, 3, 2, 1).shouldNotHaveSameDayAs(LocalDateTime.of(2014, 2, 6, 3, 2, 1))151 }152 "ZonedDateTime should have same day ignoring other fields" {153 LocalDateTime.of(2014, 1, 2, 4, 3, 2).atZone(ZoneId.of("Z")) should haveSameDay(LocalDateTime.of(2014, 1, 2, 3, 2, 1).atZone(ZoneId.of("Z")))154 LocalDateTime.of(2014, 1, 2, 3, 2, 1).atZone(ZoneId.of("Z")) shouldNot haveSameDay(LocalDateTime.of(2014, 2, 6, 3, 2, 1).atZone(ZoneId.of("Z")))155 LocalDateTime.of(2014, 1, 2, 4, 3, 2).atZone(ZoneId.of("Z")).shouldHaveSameDayAs(LocalDateTime.of(2014, 1, 2, 3, 2, 1).atZone(ZoneId.of("Z")))156 LocalDateTime.of(2014, 1, 2, 3, 2, 1).atZone(ZoneId.of("Z")).shouldNotHaveSameDayAs(LocalDateTime.of(2014, 2, 6, 3, 2, 1).atZone(ZoneId.of("Z")))157 }158 "OffsetDateTime should have same day ignoring other fields" {159 LocalDateTime.of(2014, 1, 2, 4, 3, 2).atOffset(ZoneOffset.UTC) should haveSameDay(LocalDateTime.of(2014, 1, 2, 3, 2, 1).atOffset(ZoneOffset.UTC))160 LocalDateTime.of(2014, 1, 2, 3, 2, 1).atOffset(ZoneOffset.UTC) shouldNot haveSameDay(LocalDateTime.of(2014, 2, 6, 3, 2, 1).atOffset(ZoneOffset.UTC))161 LocalDateTime.of(2014, 1, 2, 4, 3, 2).atOffset(ZoneOffset.UTC).shouldHaveSameDayAs(LocalDateTime.of(2014, 1, 2, 3, 2, 1).atOffset(ZoneOffset.UTC))162 LocalDateTime.of(2014, 1, 2, 3, 2, 1).atOffset(ZoneOffset.UTC).shouldNotHaveSameDayAs(LocalDateTime.of(2014, 2, 6, 3, 2, 1).atOffset(ZoneOffset.UTC))163 }164 "LocalTime shouldBe before" {165 LocalTime.of(1, 2, 3, 1000) shouldBe before(LocalTime.of(1, 10, 3, 1000))166 LocalTime.of(1, 2, 3, 1000) shouldNotBe before(LocalTime.of(1, 1, 3, 1000))167 LocalTime.of(1, 2, 3, 1000).shouldBeBefore(LocalTime.of(5, 2, 3, 1000))168 LocalTime.of(1, 2, 3, 1000).shouldNotBeBefore(LocalTime.of(0, 2, 3, 1000))169 }170 "LocalDate shouldBe before" {171 LocalDate.of(2014, 1, 2) shouldBe before(LocalDate.of(2014, 1, 3))172 LocalDate.of(2014, 1, 2) shouldNotBe before(LocalDate.of(2014, 1, 1))173 LocalDate.of(2014, 1, 2).shouldBeBefore(LocalDate.of(2014, 1, 3))174 LocalDate.of(2014, 1, 2).shouldNotBeBefore(LocalDate.of(2014, 1, 1))175 }176 "LocalDateTime shouldBe before" {177 LocalDateTime.of(2014, 1, 2, 4, 3, 2) shouldBe before(LocalDateTime.of(2014, 2, 2, 3, 2, 1))178 LocalDateTime.of(2014, 1, 2, 3, 2, 1) shouldNotBe before(LocalDateTime.of(2014, 1, 1, 3, 2, 1))179 LocalDateTime.of(2014, 1, 2, 4, 3, 2).shouldBeBefore(LocalDateTime.of(2014, 2, 2, 3, 2, 1))180 LocalDateTime.of(2014, 1, 2, 3, 2, 1).shouldNotBeBefore(LocalDateTime.of(2014, 1, 1, 3, 2, 1))181 }182 "ZonedDateTime shouldBe before" {183 LocalDateTime.of(2014, 1, 2, 4, 3, 2).atZone(ZoneId.of("Z")) shouldBe before(LocalDateTime.of(2014, 1, 3, 3, 2, 1).atZone(ZoneId.of("Z")))184 LocalDateTime.of(2014, 1, 2, 3, 2, 1).atZone(ZoneId.of("Z")) shouldNotBe before(LocalDateTime.of(2014, 1, 1, 3, 2, 1).atZone(ZoneId.of("Z")))185 LocalDateTime.of(2014, 1, 2, 4, 3, 2).atZone(ZoneId.of("Z")).shouldBeBefore(LocalDateTime.of(2014, 1, 3, 3, 2, 1).atZone(ZoneId.of("Z")))186 LocalDateTime.of(2014, 1, 2, 3, 2, 1).atZone(ZoneId.of("Z")).shouldNotBeBefore(LocalDateTime.of(2014, 1, 1, 3, 2, 1).atZone(ZoneId.of("Z")))187 }188 "ZonedDateTime shouldBe equal" {189 ZonedDateTime.of(2019, 12, 10, 10, 0, 0, 0, ZoneOffset.UTC) shouldBe190 ZonedDateTime.of(2019, 12, 10, 4, 0, 0, 0, ZoneId.of("America/Chicago")).atSameZone()191 shouldThrow<AssertionError> {192 ZonedDateTime.of(2019, 12, 10, 10, 0, 0, 0, ZoneOffset.UTC) shouldBe193 ZonedDateTime.of(2019, 12, 10, 4, 1, 0, 0, ZoneId.of("America/Chicago")).atSameZone()194 }.message shouldBe "expected:<2019-12-10T10:01Z> but was:<2019-12-10T10:00Z>"195 }196 "OffsetDateTime shouldBe before" {197 LocalDateTime.of(2014, 1, 2, 4, 3, 2).atOffset(ZoneOffset.UTC) shouldBe before(LocalDateTime.of(2016, 1, 2, 3, 2, 1).atOffset(ZoneOffset.UTC))198 LocalDateTime.of(2014, 1, 2, 3, 2, 1).atOffset(ZoneOffset.UTC) shouldNotBe before(LocalDateTime.of(2012, 2, 6, 3, 2, 1).atOffset(ZoneOffset.UTC))199 LocalDateTime.of(2014, 1, 2, 4, 3, 2).atOffset(ZoneOffset.UTC).shouldBeBefore(LocalDateTime.of(2016, 1, 2, 3, 2, 1).atOffset(ZoneOffset.UTC))200 LocalDateTime.of(2014, 1, 2, 3, 2, 1).atOffset(ZoneOffset.UTC).shouldNotBeBefore(LocalDateTime.of(2012, 2, 6, 3, 2, 1).atOffset(ZoneOffset.UTC))201 }202 "LocalTime shouldBe after" {203 LocalTime.of(1, 2, 3, 9999) shouldBe after(LocalTime.of(1, 2, 3, 1111))204 LocalTime.of(1, 2, 3, 1000) shouldNotBe after(LocalTime.of(1, 2, 10, 1000))205 LocalTime.of(1, 2, 3, 9999).shouldBeAfter(LocalTime.of(1, 2, 3, 1111))206 LocalTime.of(1, 2, 3, 1000).shouldNotBeAfter(LocalTime.of(1, 2, 10, 1000))207 }208 "LocalDate shouldBe after" {209 LocalDate.of(2014, 1, 2) shouldBe after(LocalDate.of(2013, 1, 3))210 LocalDate.of(2014, 1, 2) shouldNotBe after(LocalDate.of(2014, 1, 3))211 LocalDate.of(2014, 1, 2).shouldBeAfter(LocalDate.of(2013, 1, 3))212 LocalDate.of(2014, 1, 2).shouldNotBeAfter(LocalDate.of(2014, 1, 3))213 }214 "LocalDateTime shouldBe after" {215 LocalDateTime.of(2014, 1, 2, 4, 3, 2) shouldBe after(LocalDateTime.of(2014, 1, 1, 3, 2, 1))216 LocalDateTime.of(2014, 1, 2, 3, 2, 1) shouldNotBe after(LocalDateTime.of(2014, 1, 3, 3, 2, 1))217 LocalDateTime.of(2014, 1, 2, 4, 3, 2).shouldBeAfter(LocalDateTime.of(2014, 1, 1, 3, 2, 1))218 LocalDateTime.of(2014, 1, 2, 3, 2, 1).shouldNotBeAfter(LocalDateTime.of(2014, 1, 3, 3, 2, 1))219 }220 "ZonedDateTime shouldBe after" {221 LocalDateTime.of(2014, 1, 2, 4, 3, 2).atZone(ZoneId.of("Z")) shouldBe after(LocalDateTime.of(2014, 1, 1, 3, 2, 1).atZone(ZoneId.of("Z")))222 LocalDateTime.of(2014, 1, 2, 3, 2, 1).atZone(ZoneId.of("Z")) shouldNotBe after(LocalDateTime.of(2014, 1, 3, 3, 2, 1).atZone(ZoneId.of("Z")))223 LocalDateTime.of(2014, 1, 2, 4, 3, 2).atZone(ZoneId.of("Z")).shouldBeAfter(LocalDateTime.of(2014, 1, 1, 3, 2, 1).atZone(ZoneId.of("Z")))224 LocalDateTime.of(2014, 1, 2, 3, 2, 1).atZone(ZoneId.of("Z")).shouldNotBeAfter(LocalDateTime.of(2014, 1, 3, 3, 2, 1).atZone(ZoneId.of("Z")))225 }226 "OffsetDateTime shouldBe after" {227 LocalDateTime.of(2014, 1, 2, 4, 3, 2).atOffset(ZoneOffset.UTC) shouldBe after(LocalDateTime.of(2014, 1, 1, 3, 2, 1).atOffset(ZoneOffset.UTC))228 LocalDateTime.of(2014, 1, 2, 3, 2, 1).atOffset(ZoneOffset.UTC) shouldNotBe after(LocalDateTime.of(2014, 2, 1, 3, 2, 1).atOffset(ZoneOffset.UTC))229 LocalDateTime.of(2014, 1, 2, 4, 3, 2).atOffset(ZoneOffset.UTC).shouldBeAfter(LocalDateTime.of(2014, 1, 1, 3, 2, 1).atOffset(ZoneOffset.UTC))230 LocalDateTime.of(2014, 1, 2, 3, 2, 1).atOffset(ZoneOffset.UTC).shouldNotBeAfter(LocalDateTime.of(2014, 2, 1, 3, 2, 1).atOffset(ZoneOffset.UTC))231 }232 "LocalDate shouldBe within(period, date)" {233 LocalDate.of(2014, 1, 2) shouldBe within(Period.ofDays(3), LocalDate.of(2014, 1, 1))234 LocalDate.of(2014, 1, 2) shouldBe within(Period.ofDays(3), LocalDate.of(2014, 1, 5))235 LocalDate.of(2014, 1, 2) shouldNotBe within(Period.ofDays(3), LocalDate.of(2014, 1, 6))236 LocalDate.of(2014, 1, 2).shouldBeWithin(Period.ofDays(3), LocalDate.of(2014, 1, 5))237 LocalDate.of(2014, 1, 2).shouldNotBeWithin(Period.ofDays(3), LocalDate.of(2014, 1, 6))238 }239 "LocalDateTime shouldBe within(period, date)" {240 LocalDateTime.of(2014, 1, 2, 4, 3, 2) shouldBe within(Period.ofDays(1), LocalDateTime.of(2014, 1, 2, 9, 3, 2))241 LocalDateTime.of(2014, 1, 2, 3, 2, 1) shouldNotBe within(Period.ofDays(1), LocalDateTime.of(2014, 1, 3, 3, 2, 2))242 LocalDateTime.of(2014, 1, 2, 4, 3, 2).shouldBeWithin(Period.ofDays(1), LocalDateTime.of(2014, 1, 2, 9, 3, 2))243 LocalDateTime.of(2014, 1, 2, 3, 2, 1).shouldNotBeWithin(Period.ofDays(1), LocalDateTime.of(2014, 1, 3, 3, 2, 2))244 }245 "ZonedDateTime shouldBe within(period, date)" {246 LocalDateTime.of(2014, 1, 2, 4, 3, 2).atZone(ZoneId.of("Z")) shouldBe within(Period.ofDays(1), LocalDateTime.of(2014, 1, 3, 4, 3, 2).atZone(ZoneId.of("Z")))247 LocalDateTime.of(2014, 1, 2, 4, 3, 2).atZone(ZoneId.of("Z")) shouldBe within(Period.ofDays(1), LocalDateTime.of(2014, 1, 1, 4, 3, 2).atZone(ZoneId.of("Z")))248 LocalDateTime.of(2014, 1, 2, 4, 3, 2).atZone(ZoneId.of("Z")) shouldBe within(Period.ofDays(1), LocalDateTime.of(2014, 1, 2, 9, 3, 2).atZone(ZoneId.of("Z")))249 LocalDateTime.of(2014, 1, 2, 3, 2, 1).atZone(ZoneId.of("Z")) shouldNotBe within(Period.ofDays(1), LocalDateTime.of(2014, 1, 3, 3, 2, 2).atZone(ZoneId.of("Z")))250 LocalDateTime.of(2014, 1, 2, 3, 2, 1).atZone(ZoneId.of("Z")) shouldNotBe within(Period.ofDays(1), LocalDateTime.of(2014, 1, 1, 3, 2, 0).atZone(ZoneId.of("Z")))251 LocalDateTime.of(2014, 1, 2, 4, 3, 2).atZone(ZoneId.of("Z")).shouldBeWithin(Period.ofDays(1), LocalDateTime.of(2014, 1, 3, 4, 3, 2).atZone(ZoneId.of("Z")))252 LocalDateTime.of(2014, 1, 2, 4, 3, 2).atZone(ZoneId.of("Z")).shouldBeWithin(Period.ofDays(1), LocalDateTime.of(2014, 1, 1, 4, 3, 2).atZone(ZoneId.of("Z")))253 LocalDateTime.of(2014, 1, 2, 4, 3, 2).atZone(ZoneId.of("Z")).shouldBeWithin(Period.ofDays(1), LocalDateTime.of(2014, 1, 2, 9, 3, 2).atZone(ZoneId.of("Z")))254 LocalDateTime.of(2014, 1, 2, 3, 2, 1).atZone(ZoneId.of("Z")).shouldNotBeWithin(Period.ofDays(1), LocalDateTime.of(2014, 1, 3, 3, 2, 2).atZone(ZoneId.of("Z")))255 LocalDateTime.of(2014, 1, 2, 3, 2, 1).atZone(ZoneId.of("Z")).shouldNotBeWithin(Period.ofDays(1), LocalDateTime.of(2014, 1, 1, 3, 2, 0).atZone(ZoneId.of("Z")))256 }257 "ZonedDateTime shouldBe within(duration, date)" {258 LocalDateTime.of(2014, 1, 2, 4, 3, 2).atZone(ZoneId.of("Z")) shouldBe within(Duration.ofDays(1), LocalDateTime.of(2014, 1, 3, 4, 3, 2).atZone(ZoneId.of("Z")))259 LocalDateTime.of(2014, 1, 2, 4, 3, 2).atZone(ZoneId.of("Z")) shouldBe within(Duration.ofDays(1), LocalDateTime.of(2014, 1, 1, 4, 3, 2).atZone(ZoneId.of("Z")))260 LocalDateTime.of(2014, 1, 2, 4, 3, 2).atZone(ZoneId.of("Z")) shouldBe within(Duration.ofDays(1), LocalDateTime.of(2014, 1, 2, 9, 3, 2).atZone(ZoneId.of("Z")))261 LocalDateTime.of(2014, 1, 2, 3, 2, 1).atZone(ZoneId.of("Z")) shouldNotBe within(Duration.ofDays(1), LocalDateTime.of(2014, 1, 3, 3, 2, 2).atZone(ZoneId.of("Z")))262 LocalDateTime.of(2014, 1, 2, 3, 2, 1).atZone(ZoneId.of("Z")) shouldNotBe within(Duration.ofDays(1), LocalDateTime.of(2014, 1, 1, 3, 2, 0).atZone(ZoneId.of("Z")))263 LocalDateTime.of(2014, 1, 2, 4, 3, 2).atZone(ZoneId.of("Z")).shouldBeWithin(Duration.ofDays(1), LocalDateTime.of(2014, 1, 3, 4, 3, 2).atZone(ZoneId.of("Z")))264 LocalDateTime.of(2014, 1, 2, 4, 3, 2).atZone(ZoneId.of("Z")).shouldBeWithin(Duration.ofDays(1), LocalDateTime.of(2014, 1, 1, 4, 3, 2).atZone(ZoneId.of("Z")))265 LocalDateTime.of(2014, 1, 2, 4, 3, 2).atZone(ZoneId.of("Z")).shouldBeWithin(Duration.ofDays(1), LocalDateTime.of(2014, 1, 2, 9, 3, 2).atZone(ZoneId.of("Z")))266 LocalDateTime.of(2014, 1, 2, 3, 2, 1).atZone(ZoneId.of("Z")).shouldNotBeWithin(Duration.ofDays(1), LocalDateTime.of(2014, 1, 3, 3, 2, 2).atZone(ZoneId.of("Z")))267 LocalDateTime.of(2014, 1, 2, 3, 2, 1).atZone(ZoneId.of("Z")).shouldNotBeWithin(Duration.ofDays(1), LocalDateTime.of(2014, 1, 1, 3, 2, 0).atZone(ZoneId.of("Z")))268 }269 "OffsetDateTime shouldBe within(period, date)" {270 LocalDateTime.of(2014, 1, 2, 4, 3, 2).atOffset(ZoneOffset.UTC) shouldBe within(Period.ofDays(1), LocalDateTime.of(2014, 1, 3, 4, 3, 2).atOffset(ZoneOffset.UTC))271 LocalDateTime.of(2014, 1, 2, 3, 2, 1).atOffset(ZoneOffset.UTC) shouldNotBe within(Period.ofDays(1), LocalDateTime.of(2014, 2, 1, 3, 2, 1).atOffset(ZoneOffset.UTC))272 LocalDateTime.of(2014, 1, 2, 4, 3, 2).atOffset(ZoneOffset.UTC).shouldBeWithin(Period.ofDays(1), LocalDateTime.of(2014, 1, 3, 4, 3, 2).atOffset(ZoneOffset.UTC))273 LocalDateTime.of(2014, 1, 2, 3, 2, 1).atOffset(ZoneOffset.UTC).shouldNotBeWithin(Period.ofDays(1), LocalDateTime.of(2014, 2, 1, 3, 2, 1).atOffset(ZoneOffset.UTC))274 }275 "OffsetDateTime shouldBe within(duration, date)" {276 LocalDateTime.of(2014, 1, 2, 4, 3, 2).atOffset(ZoneOffset.UTC) shouldBe within(Duration.ofDays(1), LocalDateTime.of(2014, 1, 3, 4, 3, 2).atOffset(ZoneOffset.UTC))277 LocalDateTime.of(2014, 1, 2, 3, 2, 1).atOffset(ZoneOffset.UTC) shouldNotBe within(Duration.ofDays(1), LocalDateTime.of(2014, 2, 1, 3, 2, 1).atOffset(ZoneOffset.UTC))278 LocalDateTime.of(2014, 1, 2, 4, 3, 2).atOffset(ZoneOffset.UTC).shouldBeWithin(Duration.ofDays(1), LocalDateTime.of(2014, 1, 3, 4, 3, 2).atOffset(ZoneOffset.UTC))279 LocalDateTime.of(2014, 1, 2, 3, 2, 1).atOffset(ZoneOffset.UTC).shouldNotBeWithin(Duration.ofDays(1), LocalDateTime.of(2014, 2, 1, 3, 2, 1).atOffset(ZoneOffset.UTC))280 }281 "LocalTime shouldBe between" {282 LocalTime.of(14, 20, 50, 1000).shouldBeBetween(LocalTime.of(14, 20, 49), LocalTime.of(14, 20, 51))283 LocalTime.of(14, 20, 50, 1000).shouldNotBeBetween(LocalTime.of(14, 20, 51), LocalTime.of(14, 20, 52))284 }285 "LocalDate shouldBe between" {286 LocalDate.of(2019, 2, 16).shouldBeBetween(LocalDate.of(2019, 2, 15), LocalDate.of(2019, 2, 17))287 LocalDate.of(2019, 2, 16).shouldNotBeBetween(LocalDate.of(2019, 2, 17), LocalDate.of(2019, 2, 18))288 }289 "LocalDateTime shouldBe between" {290 LocalDateTime.of(2019, 2, 16, 12, 0, 0).shouldBeBetween(LocalDateTime.of(2019, 2, 15, 12, 0, 0), LocalDateTime.of(2019, 2, 17, 12, 0, 0))291 LocalDateTime.of(2019, 2, 16, 12, 0, 0).shouldBeBetween(LocalDateTime.of(2019, 2, 16, 10, 0, 0), LocalDateTime.of(2019, 2, 16, 14, 0, 0))292 LocalDateTime.of(2019, 2, 16, 12, 0, 0).shouldNotBeBetween(LocalDateTime.of(2019, 2, 17, 12, 0, 0), LocalDateTime.of(2019, 2, 18, 12, 0, 0))293 LocalDateTime.of(2019, 2, 16, 12, 0, 0).shouldNotBeBetween(LocalDateTime.of(2019, 2, 16, 18, 0, 0), LocalDateTime.of(2019, 2, 16, 20, 0, 0))294 }295 "ZonedDateTime shouldBe between" {296 ZonedDateTime.of(2019, 2, 16, 12, 0, 0, 0, ZoneId.of("America/Sao_Paulo")).shouldBeBetween(ZonedDateTime.of(2019, 2, 15, 12, 0, 0, 0, ZoneId.of("America/Sao_Paulo")), ZonedDateTime.of(2019, 2, 17, 12, 0, 0, 0, ZoneId.of("America/Sao_Paulo")))297 ZonedDateTime.of(2019, 2, 16, 12, 0, 0, 0, ZoneId.of("America/Sao_Paulo")).shouldNotBeBetween(ZonedDateTime.of(2019, 2, 17, 12, 0, 0, 0, ZoneId.of("America/Sao_Paulo")), ZonedDateTime.of(2019, 2, 18, 12, 0, 0, 0, ZoneId.of("America/Sao_Paulo")))298 }299 "OffsetDateTime shouldBe between" {300 OffsetDateTime.of(2019, 2, 16, 12, 0, 0, 0, ZoneOffset.ofHours(-3)).shouldBeBetween(OffsetDateTime.of(2019, 2, 15, 12, 0, 0, 0, ZoneOffset.ofHours(-3)), OffsetDateTime.of(2019, 2, 17, 12, 0, 0, 0, ZoneOffset.ofHours(-3)))301 OffsetDateTime.of(2019, 2, 15, 12, 0, 0, 0, ZoneOffset.ofHours(-3)).shouldNotBeBetween(OffsetDateTime.of(2019, 2, 16, 12, 0, 0, 0, ZoneOffset.ofHours(-3)), OffsetDateTime.of(2019, 2, 17, 12, 0, 0, 0, ZoneOffset.ofHours(-3)))302 }303 "LocalDate.shouldBeToday() should match today" {304 LocalDate.now().shouldBeToday()305 }306 "LocalDateTime.shouldBeToday() should match today" {307 LocalDateTime.now().shouldBeToday()308 }309 "LocalDate.shouldBeToday() should not match the past" {310 shouldFail {311 LocalDate.of(2002, Month.APRIL, 1).shouldBeToday()312 }313 }314 "LocalDateTime.shouldBeToday() should not match the past" {315 shouldFail {316 LocalDateTime.of(2002, Month.APRIL, 1, 5, 2).shouldBeToday()317 }318 shouldFail {319 LocalDateTime.now().minusDays(1).shouldBeToday()320 }321 }322 "LocalDateTime.shouldNotBeToday()" {323 LocalDateTime.of(2002, Month.APRIL, 1, 5, 2).shouldNotBeToday()324 shouldFail {325 LocalDateTime.now().shouldNotBeToday()326 }327 }328 "LocalDate.shouldNotBeToday()" {329 LocalDate.of(2002, Month.APRIL, 2).shouldNotBeToday()330 shouldFail {331 LocalDateTime.now().shouldNotBeToday()332 }333 }334 "LocalDateTime should have day of month (day)" {335 LocalDateTime.of(2019, 2, 16, 12, 0, 0, 0) shouldHaveDayOfMonth 16336 }337 "LocalDateTime should have day of week" {338 LocalDateTime.of(2019, 2, 16, 12, 0, 0, 0) shouldHaveDayOfWeek SATURDAY339 LocalDateTime.of(2019, 2, 16, 12, 0, 0, 0) shouldHaveDayOfWeek 6340 }341 "LocalDateTime should have day of year" {342 LocalDateTime.of(2019, 2, 16, 12, 0, 0, 0) shouldHaveDayOfYear 47343 }344 "LocalDateTime should have month" {345 LocalDateTime.of(2019, 2, 16, 12, 0, 0, 0) shouldHaveMonth 2346 LocalDateTime.of(2019, 2, 16, 12, 0, 0, 0) shouldHaveMonth Month.FEBRUARY347 }348 "LocalDateTime should have hour" {349 LocalDateTime.of(2019, 2, 16, 12, 10, 0, 0) shouldHaveHour 12350 }351 "LocalDateTime should have minute" {352 LocalDateTime.of(2019, 2, 16, 12, 10, 0, 0) shouldHaveMinute 10353 }354 "LocalDateTime should have second" {355 LocalDateTime.of(2019, 2, 16, 12, 10, 13, 0) shouldHaveSecond 13356 }357 "LocalDateTime should have nano" {358 LocalDateTime.of(2019, 2, 16, 12, 10, 0, 14) shouldHaveNano 14359 }360 "ZonedDateTime should be have same instant of the given ZonedDateTime irrespective of their timezone" {361 ZonedDateTime.of(2019, 2, 16, 11, 0, 0, 0, ZoneOffset.ofHours(-1)) should haveSameInstantAs(ZonedDateTime.of(2019, 2, 16, 9, 0, 0, 0, ZoneOffset.ofHours(-3)))362 ZonedDateTime.of(2019, 2, 16, 11, 0, 0, 0, ZoneOffset.ofHours(-1)) shouldHaveSameInstantAs ZonedDateTime.of(2019, 2, 16, 9, 0, 0, 0, ZoneOffset.ofHours(-3))363 ZonedDateTime.of(2019, 2, 16, 11, 0, 0, 0, ZoneOffset.ofHours(-1)) shouldNot haveSameInstantAs(ZonedDateTime.of(2019, 2, 16, 9, 0, 0, 0, ZoneOffset.ofHours(-2)))364 ZonedDateTime.of(2019, 2, 16, 11, 0, 0, 0, ZoneOffset.ofHours(-1)) shouldNotHaveSameInstantAs ZonedDateTime.of(2019, 2, 16, 9, 0, 0, 0, ZoneOffset.ofHours(-2))365 }366 }367}...

Full Screen

Full Screen

zoneddatetime.kt

Source:zoneddatetime.kt Github

copy

Full Screen

1package io.kotest.matchers.date2import io.kotest.matchers.Matcher3import io.kotest.matchers.MatcherResult4import io.kotest.matchers.equalityMatcher5import io.kotest.matchers.should6import io.kotest.matchers.shouldNot7import java.time.ZonedDateTime8fun beInTodayZDT() = object : Matcher<ZonedDateTime> {9 override fun test(value: ZonedDateTime): MatcherResult {10 val passed = value.toLocalDate() == ZonedDateTime.now().toLocalDate()11 return MatcherResult(12 passed,13 { "$value should be today" },14 {15 "$value should not be today"16 })17 }18}19/**20 * Asserts that the ZonedDateTime does not have a date component of today21 *22 * ```23 * ZonedDateTime.of(2009, Month.APRIL, 2,2,2).shouldNotBeToday() // Assertion passes24 * ```25 */26fun ZonedDateTime.shouldNotBeToday() = this shouldNot beInTodayZDT()27/**28 * Asserts that the ZonedDateTime has a date component of today29 *30 * ```31 * ZonedDateTime.now().shouldBeToday() // Assertion passes32 * ```33 */34fun ZonedDateTime.shouldBeToday() = this should beInTodayZDT()35/**36 * Matcher that uses `actual` timezone on the `expected` ZonedDateTime37 *38 *39 * ```40 * ZonedDateTime.of(2019, 12, 10, 10, 0, 0, 0, ZoneOffset.UTC) shouldBe41 * ZonedDateTime.of(2019, 12, 10, 4, 0, 0, 0, ZoneId.of("America/Chicago")).atSameZone() // Assertion passes42 * ```43 */44fun ZonedDateTime.atSameZone() = object : Matcher<ZonedDateTime> {45 override fun test(value: ZonedDateTime): MatcherResult = equalityMatcher(withZoneSameInstant(value.zone)).test(value)46}...

Full Screen

Full Screen

ZonedDateTime.atSameZone

Using AI Code Generation

copy

Full Screen

1ZonedDateTime . atSameZone ( zonedDateTime )2ZonedDateTime . atSameZone ( zonedDateTime )3ZonedDateTime . atSameZone ( zonedDateTime )4ZonedDateTime . atSameZone ( zonedDateTime )5ZonedDateTime . atSameZone ( zonedDateTime )6ZonedDateTime . atSameZone ( zonedDateTime )7ZonedDateTime . atSameZone ( zonedDateTime )8ZonedDateTime . atSameZone ( zonedDateTime )9ZonedDateTime . atSameZone ( zonedDateTime )10ZonedDateTime . atSameZone ( zonedDateTime )11ZonedDateTime . atSameZone ( zonedDateTime )12ZonedDateTime . atSameZone ( zonedDateTime )13ZonedDateTime . atSameZone ( zonedDateTime )14ZonedDateTime . atSameZone ( zonedDateTime )15ZonedDateTime . atSameZone ( zonedDateTime )

Full Screen

Full Screen

ZonedDateTime.atSameZone

Using AI Code Generation

copy

Full Screen

1ZonedDateTime . atSameZone ( zonedDateTime1 , zonedDateTime2 )2ZonedDateTime . isBefore ( zonedDateTime1 , zonedDateTime2 )3ZonedDateTime . isAfter ( zonedDateTime1 , zonedDateTime2 )4ZonedDateTime . isEqual ( zonedDateTime1 , zonedDateTime2 )5ZonedDateTime . isEqualOrBefore ( zonedDateTime1 , zonedDateTime2 )6ZonedDateTime . isEqualOrAfter ( zonedDateTime1 , zonedDateTime2 )7ZonedDateTime . isEqualOrAfter ( zonedDateTime1 , zonedDateTime2 )8ZonedDateTime . isEqualOrAfter ( zonedDateTime1 , zonedDateTime2 )9ZonedDateTime . isEqualOrAfter ( zonedDateTime1 , zonedDateTime2 )10ZonedDateTime . isEqualOrAfter ( zonedDateTime1 , zonedDateTime2 )11ZonedDateTime . isEqualOrAfter ( zonedDateTime1 , zonedDateTime2 )12ZonedDateTime . isEqualOrAfter ( zonedDateTime1 , zonedDateTime2 )13ZonedDateTime . isEqualOrAfter ( zonedDateTime1 , zonedDateTime2 )

Full Screen

Full Screen

ZonedDateTime.atSameZone

Using AI Code Generation

copy

Full Screen

1val zonedDateTime = ZonedDateTime.now()2zonedDateTime shouldBe ZonedDateTime.atSameZone(zonedDateTime)3val zonedDateTime = ZonedDateTime.now()4zonedDateTime shouldBe ZonedDateTime.atSameInstant(zonedDateTime)5val zonedDateTime = ZonedDateTime.now()6zonedDateTime shouldBe ZonedDateTime.atSameInstant(zonedDateTime)7val zonedDateTime = ZonedDateTime.now()8zonedDateTime shouldBe ZonedDateTime.atSameInstant(zonedDateTime)9val zonedDateTime = ZonedDateTime.now()10zonedDateTime shouldBe ZonedDateTime.atSameInstant(zonedDateTime)11val zonedDateTime = ZonedDateTime.now()12zonedDateTime shouldBe ZonedDateTime.atSameInstant(zonedDateTime)13val zonedDateTime = ZonedDateTime.now()14zonedDateTime shouldBe ZonedDateTime.atSameInstant(zonedDateTime)15val zonedDateTime = ZonedDateTime.now()16zonedDateTime shouldBe ZonedDateTime.atSameInstant(zonedDateTime)17val zonedDateTime = ZonedDateTime.now()18zonedDateTime shouldBe ZonedDateTime.atSameInstant(zonedDateTime)19val zonedDateTime = ZonedDateTime.now()20zonedDateTime shouldBe ZonedDateTime.atSameInstant(zonedDateTime)21val zonedDateTime = ZonedDateTime.now()22zonedDateTime shouldBe ZonedDateTime.atSameInstant(zonedDateTime)23val zonedDateTime = ZonedDateTime.now()24zonedDateTime shouldBe ZonedDateTime.atSameInstant(zonedDateTime)

Full Screen

Full Screen

ZonedDateTime.atSameZone

Using AI Code Generation

copy

Full Screen

1import io.kotest.matchers.date.zoneddatetime.atSameZone2val zonedDateTime1 = ZonedDateTime.of(2019, 10, 28, 12, 0, 0, 0, ZoneId.of("Europe/London"))3val zonedDateTime2 = ZonedDateTime.of(2019, 10, 28, 12, 0, 0, 0, ZoneId.of("Europe/Paris"))4zonedDateTime1.atSameZone(zonedDateTime2) shouldBe zonedDateTime15import io.kotest.matchers.date.zoneddatetime.atSameZone6val zonedDateTime1 = ZonedDateTime.of(2019, 10, 28, 12, 0, 0, 0, ZoneId.of("Europe/London"))7val zonedDateTime2 = ZonedDateTime.of(2019, 10, 28, 12, 0, 0, 0, ZoneId.of("Europe/Paris"))8zonedDateTime1.atSameZone(zonedDateTime2) shouldBe zonedDateTime29import io.kotest.matchers.date.zoneddatetime.atSameZone10val zonedDateTime1 = ZonedDateTime.of(2019, 10, 28, 12, 0, 0, 0, ZoneId.of("Europe/London"))11val zonedDateTime2 = ZonedDateTime.of(2019, 10, 28, 12, 0, 0, 0, ZoneId.of("Europe/Paris"))12zonedDateTime1.atSameZone(zonedDateTime2) shouldNotBe zonedDateTime113import io.kotest.matchers.date.zoneddatetime.atSameZone14val zonedDateTime1 = ZonedDateTime.of(2019, 10, 28, 12, 0, 0, 0, ZoneId.of("Europe/London"))15val zonedDateTime2 = ZonedDateTime.of(2019, 10, 28, 12, 0, 0, 0, ZoneId.of("Europe/Paris"))16zonedDateTime1.atSameZone(zonedDateTime2) shouldNotBe zonedDateTime2

Full Screen

Full Screen

ZonedDateTime.atSameZone

Using AI Code Generation

copy

Full Screen

1val date1 = ZonedDateTime.of(2020, 1, 1, 0, 0, 0, 0, ZoneId.of("Europe/Paris"))2val date2 = ZonedDateTime.of(2020, 1, 1, 0, 0, 0, 0, ZoneId.of("Europe/Paris"))3date1 should beSameZone(date2)4val date1 = ZonedDateTime.of(2020, 1, 1, 0, 0, 0, 0, ZoneId.of("Europe/Paris"))5val date2 = ZonedDateTime.of(2020, 1, 1, 0, 0, 0, 0, ZoneId.of("Europe/London"))6date1 should not beSameZone(date2)7val date1 = ZonedDateTime.of(2020, 1, 1, 0, 0, 0, 0, ZoneId.of("Europe/Paris"))8val date2 = ZonedDateTime.of(2020, 1, 1, 0, 0, 0, 0, ZoneId.of("Europe/Paris"))9date1 should beSameZone(date2)10val date1 = ZonedDateTime.of(2020, 1, 1, 0, 0, 0, 0, ZoneId.of("Europe/Paris"))11val date2 = ZonedDateTime.of(2020, 1, 1, 0, 0, 0, 0, ZoneId.of("Europe/London"))12date1 should not beSameZone(date2)13val date1 = ZonedDateTime.of(2020,

Full Screen

Full Screen

ZonedDateTime.atSameZone

Using AI Code Generation

copy

Full Screen

1import io.kotest.matchers.date.zoneddatetime.atSameZone2import io.kotest.matchers.shouldBe3import java.time.ZonedDateTime4fun main() {5 val time = ZonedDateTime.now()6 time shouldBe atSameZone("Asia/Kolkata")7}8import io.kotest.matchers.date.zoneddatetime.atSameZone9import io.kotest.matchers.shouldBe10import java.time.ZonedDateTime11fun main() {12 val time = ZonedDateTime.now()13 time shouldBe atSameZone("Asia/Kolkata")14}15import io.kotest.matchers.date.zoneddatetime.atSameZone16import io.kotest.matchers.shouldBe17import java.time.ZonedDateTime18fun main() {19 val time = ZonedDateTime.now()20 time shouldBe atSameZone("Asia/Kolkata")21}22import io.kotest.matchers.date.zoneddatetime.atSameZone23import io.kotest.matchers.shouldBe24import java.time.ZonedDateTime25fun main() {26 val time = ZonedDateTime.now()27 time shouldBe atSameZone("Asia/Kolkata")28}29import io.kotest.matchers.date.zoneddatetime.atSameZone30import io.kotest.matchers.shouldBe31import java.time.ZonedDateTime32fun main() {33 val time = ZonedDateTime.now()34 time shouldBe atSameZone("Asia/Kolkata")35}

Full Screen

Full Screen

ZonedDateTime.atSameZone

Using AI Code Generation

copy

Full Screen

1fun `ZonedDateTime should match the same zone`(){2 val zonedDateTime = ZonedDateTime.of(2021, 1, 1, 0, 0, 0, 0, ZoneId.of("Asia/Kolkata"))3 zonedDateTime should atSameZone(ZoneId.of("Asia/Kolkata"))4}5fun `ZonedDateTime should match the same instant`(){6 val zonedDateTime = ZonedDateTime.of(2021, 1, 1, 0, 0, 0, 0, ZoneId.of("Asia/Kolkata"))7 zonedDateTime should atSameInstant(ZoneId.of("Asia/Kolkata"))8}9fun `ZonedDateTime should match the same local date time`(){10 val zonedDateTime = ZonedDateTime.of(2021, 1, 1, 0, 0, 0, 0, ZoneId.of("Asia/Kolkata"))11 zonedDateTime should atSameLocalDateTime(LocalDateTime.of(2021, 1, 1, 0, 0, 0, 0))12}13fun `ZonedDateTime should match the same local date`(){14 val zonedDateTime = ZonedDateTime.of(2021, 1, 1, 0, 0, 0, 0, ZoneId.of("Asia/Kolkata"))15 zonedDateTime should atSameLocalDate(LocalDate.of(2021, 1, 1))16}

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Kotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful