Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

add NaiveDate::abs_diff#1752

Merged
djc merged 2 commits intochronotope:mainchronotope/chrono:mainfrom
Kinrany:push-posxvswmxzkoKinrany/chrono:push-posxvswmxzkoCopy head branch name to clipboard
Oct 14, 2025
Merged

add NaiveDate::abs_diff#1752
djc merged 2 commits intochronotope:mainchronotope/chrono:mainfrom
Kinrany:push-posxvswmxzkoKinrany/chrono:push-posxvswmxzkoCopy head branch name to clipboard

Conversation

@Kinrany
Copy link
Copy Markdown
Contributor

@Kinrany Kinrany commented Oct 13, 2025

Adds NaiveDate::abs_diff, a method for calculating the distance between two NaiveDates expressed in days.

The other option is to implement this on NaiveDate only, so that there are no surprises around the time component being ignored for this purpose.

Closes #1746

@codecov
Copy link
Copy Markdown

codecov bot commented Oct 13, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.90%. Comparing base (e632ffd) to head (b94ba77).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1752   +/-   ##
=======================================
  Coverage   90.90%   90.90%           
=======================================
  Files          39       39           
  Lines       16254    16262    +8     
=======================================
+ Hits        14775    14783    +8     
  Misses       1479     1479           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@djc
Copy link
Copy Markdown
Member

djc commented Oct 13, 2025

Only on NaiveDate sounds good to me.

@Kinrany Kinrany changed the title add Datelike::days_between add NaiveDate::abs_diff Oct 14, 2025
@Kinrany Kinrany marked this pull request as ready for review October 14, 2025 14:57
@Kinrany
Copy link
Copy Markdown
Contributor Author

Kinrany commented Oct 14, 2025

I couldn't come up with a name that I'd really like. "days_since" implies that one date is greater, "days_between" implies an open interval and would be a source of many off-by-one errors.

@djc djc merged commit 334565c into chronotope:main Oct 14, 2025
35 checks passed
@Kinrany
Copy link
Copy Markdown
Contributor Author

Kinrany commented Oct 14, 2025

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Method to get num days between two NaiveDates

2 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.