Skip to content

Commit

Permalink
Fix tides being returned for more than one day
Browse files Browse the repository at this point in the history
  • Loading branch information
kylecorry31 committed Jan 20, 2024
1 parent ce8d169 commit e492c7a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ class TideService : ITideService {
val end = date.plusDays(1).atStartOfDay().toZonedDateTime(zone)
val waterLevelCalculator = TideTableWaterLevelCalculator(table)
val extremaFinder = GoldenRatioExtremaFinder(30.0, 1.0)
return ocean.getTides(waterLevelCalculator, start, end, extremaFinder)
val tides = ocean.getTides(waterLevelCalculator, start, end, extremaFinder)
return tides.filter { it.time.toLocalDate() == date }
}

private fun LocalDateTime.toZonedDateTime(zone: ZoneId): ZonedDateTime {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ internal class TideServiceTest {
if (exact) 0.0001f else 1.5f
)
val delta = Duration.between(actual.time, expected.time).seconds / 60f
Assertions.assertEquals(0f, delta, if (exact) 0f else 90f)
Assertions.assertEquals(0f, delta, if (exact) 1f else 90f)
}
}

Expand Down

0 comments on commit e492c7a

Please sign in to comment.