Skip to content

Commit 9fd3885

Browse files
committed
Try to find the edge cases that work across platforms
1 parent c96d955 commit 9fd3885

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

core/common/test/samples/InstantSamples.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,11 +234,11 @@ class InstantSamples {
234234

235235
@Test
236236
fun minusDateTimeUnit() {
237-
val startInstant = Instant.parse("2024-05-02T08:55:40.322Z")
237+
val startInstant = Instant.parse("2024-03-28T02:04:56.256Z")
238238
val twoYearsEarlierInBerlin = startInstant.minus(2, DateTimeUnit.YEAR, TimeZone.of("Europe/Berlin"))
239-
check(twoYearsEarlierInBerlin == Instant.parse("2022-05-02T08:55:40.322Z"))
239+
check(twoYearsEarlierInBerlin == Instant.parse("2022-03-28T01:04:56.256Z"))
240240
val twoYearsEarlierInCairo = startInstant.minus(2, DateTimeUnit.YEAR, TimeZone.of("Africa/Cairo"))
241-
check(twoYearsEarlierInCairo == Instant.parse("2022-05-02T09:55:40.322Z"))
241+
check(twoYearsEarlierInCairo == Instant.parse("2022-03-28T02:04:56.256Z"))
242242
}
243243

244244
@Test

core/common/test/samples/TimeZoneSamples.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ package kotlinx.datetime.test.samples
77

88
import kotlinx.datetime.*
99
import kotlinx.datetime.format.*
10+
import kotlin.random.*
1011
import kotlin.test.*
1112

1213
class TimeZoneSamples {
@@ -174,16 +175,15 @@ class TimeZoneSamples {
174175
check(instant == Instant.parse("2023-06-02T11:00:00Z"))
175176
}
176177

177-
@Ignore // fails on Windows; TODO investigate
178178
@Test
179179
fun atStartOfDayIn() {
180-
val zone = TimeZone.of("America/Cuiaba")
180+
val zone = TimeZone.of("Africa/Cairo")
181181
// The normal case where `atStartOfDayIn` returns the instant of 00:00:00 in the given time zone.
182182
val normalDate = LocalDate(2023, 6, 2)
183183
val startOfDay = normalDate.atStartOfDayIn(zone)
184184
check(startOfDay.toLocalDateTime(zone) == normalDate.atTime(hour = 0, minute = 0))
185185
// The edge case where 00:00:00 does not exist in this time zone on this date due to clocks moving forward.
186-
val dateWithoutMidnight = LocalDate(1985, 11, 2)
186+
val dateWithoutMidnight = LocalDate(2023, 4, 28)
187187
val startOfDayWithoutMidnight = dateWithoutMidnight.atStartOfDayIn(zone)
188188
check(startOfDayWithoutMidnight.toLocalDateTime(zone) == dateWithoutMidnight.atTime(hour = 1, minute = 0))
189189
}

0 commit comments

Comments
 (0)