Repository navigation
Conversation
granularity="month" and "quarter" divided the elapsed seconds by a fixed 30.5-day month, so whole calendar months were under-counted: Jan 1 -> Mar 1 was "in a month" and exactly 3 months was "in 0 quarters". Count calendar months with relativedelta, as the auto granularity does.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1391 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 10 10
Lines 2315 2321 +6
Branches 358 358
=========================================
+ Hits 2315 2321 +6 ☔ View full report in Codecov by Harness. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request Checklist
toxormake testto find out!).tox -e lintormake lintto find out!).masterbranch.Description of Changes
With a single
granularity="month"or"quarter",humanizedivided the elapsed seconds by a fixed 30.5-day month (91.5-day quarter). Whole calendar months were then under-counted:The
"auto"granularity already counts calendar months withrelativedelta. This change does the same for the single month and quarter granularities. The partial month is added as a fraction of the next calendar month, so it stays below 1 and keeps the "ago"/"in" direction when the count is 0 (e.g. Jan 1 → Jan 31 23:59 is still "0 months ago").Multi-granularity lists are not changed here. #1367 handles those separately.
Tests
test_granularity_calendar_monthschecks 1/2/6 months and 3/6/18-month quarters from Jan 31 (with month-end clamping), plus the "0 months" case for a span longer than 30.5 days. It fails without the fix.later506is 2013-01-01 → 2014-08-02 16:53, which is 19 calendar months, not 18.pre-commit(black, flake8, isort, mypy) is clean on the changed files.AI-assisted (Claude): I used it to help read the code and draft the test. I reviewed and ran everything myself.