Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide LocalDate interpolator #446

Merged
merged 1 commit into from
Jan 28, 2025
Merged

Conversation

twyatt
Copy link
Member

@twyatt twyatt commented Jan 7, 2025

No description provided.

@twyatt twyatt added the minor Changes that should bump the MINOR version number label Jan 7, 2025
@twyatt twyatt force-pushed the twyatt/LocalDate-interpolator branch 2 times, most recently from cc097ea to 952797f Compare January 7, 2025 21:15
private val range = stop.toEpochDays() - start.toEpochDays()

override fun interpolate(fraction: Float): LocalDate =
start + DatePeriod(days = (range * fraction).roundToInt())
Copy link
Member Author

@twyatt twyatt Jan 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't sure if roundToInt (vs. just toInt) is the best approach here?

Note

I tried using toInt, and 2 (of the 3) LinearLocalDateInterpolator tests (in this PR) failed, so I think roundToInt is the correct approach.

Copy link

github-actions bot commented Jan 7, 2025

Test Results

 66 files  + 4   66 suites  +4   10s ⏱️ -1s
333 tests +12  333 ✅ +12  0 💤 ±0  0 ❌ ±0 
378 runs  +12  378 ✅ +12  0 💤 ±0  0 ❌ ±0 

Results for commit 2284488. ± Comparison against base commit 449a1a0.

♻️ This comment has been updated with latest results.

@twyatt twyatt force-pushed the twyatt/LocalDate-interpolator branch 2 times, most recently from 23e4630 to b1e5a6e Compare January 27, 2025 01:47
@twyatt twyatt marked this pull request as ready for review January 27, 2025 01:50
@twyatt twyatt requested review from cedrickcooke and a team as code owners January 27, 2025 01:50
@twyatt twyatt requested a review from Phoenix7351 January 27, 2025 01:50
@twyatt twyatt force-pushed the twyatt/LocalDate-interpolator branch from b1e5a6e to 2284488 Compare January 27, 2025 02:10
Copy link
Contributor

@cedrickcooke cedrickcooke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rounding should be fine. Going from continuous (float) to discrete (local date) is always a little funky.

@twyatt twyatt merged commit 61dc64e into main Jan 28, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
minor Changes that should bump the MINOR version number
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants