-
-
Notifications
You must be signed in to change notification settings - Fork 735
Revert "Fix humanize reporting 'a month' for 16-day differences" #1264
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1223,10 +1223,8 @@ def humanize( | |
| calendar_diff.years * self._MONTHS_PER_YEAR + calendar_diff.months | ||
| ) | ||
|
|
||
| # Round up partial months when already at least one | ||
| # calendar month has elapsed and the remaining days | ||
| # are more than halfway through another month. | ||
| if calendar_months >= 1 and calendar_diff.days > 14: | ||
| # For months, if more than 2 weeks, count as a full month | ||
| if calendar_diff.days > 14: | ||
| calendar_months += 1 | ||
|
Comment on lines
+1226
to
1228
|
||
|
|
||
| calendar_months = min(calendar_months, self._MONTHS_PER_YEAR) | ||
|
|
@@ -1238,13 +1236,6 @@ def humanize( | |
| days = sign * max(delta_second // self._SECS_PER_DAY, 2) | ||
| return locale.describe("days", days, only_distance=only_distance) | ||
|
|
||
| elif diff < self._SECS_PER_WEEK * 2 and calendar_months < 1: | ||
| return locale.describe("week", sign, only_distance=only_distance) | ||
|
|
||
| elif calendar_months < 1 and diff < self._SECS_PER_MONTH: | ||
| weeks = sign * max(delta_second // self._SECS_PER_WEEK, 2) | ||
| return locale.describe("weeks", weeks, only_distance=only_distance) | ||
|
|
||
| elif calendar_months >= 1 and diff < self._SECS_PER_YEAR: | ||
| if calendar_months == 1: | ||
| return locale.describe( | ||
|
|
@@ -1256,6 +1247,13 @@ def humanize( | |
| "months", months, only_distance=only_distance | ||
| ) | ||
|
|
||
| elif diff < self._SECS_PER_WEEK * 2: | ||
| return locale.describe("week", sign, only_distance=only_distance) | ||
|
|
||
| elif diff < self._SECS_PER_MONTH: | ||
| weeks = sign * max(delta_second // self._SECS_PER_WEEK, 2) | ||
| return locale.describe("weeks", weeks, only_distance=only_distance) | ||
|
|
||
| elif diff < self._SECS_PER_YEAR * 2: | ||
| return locale.describe("year", sign, only_distance=only_distance) | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
calendar_monthsis incremented whenevercalendar_diff.days > 14, even whencalendar_monthsis currently 0. That means a pure ~15–29 day difference (e.g., 16 days) will be humanized as "a month" instead of weeks/days, reintroducing the behavior that #1242 tried to fix. If the intent is to avoid reporting months unless at least one calendar month has elapsed, restore thecalendar_months >= 1guard (or otherwise ensure sub-month differences don’t get rounded up into 1 month).