| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
When a tz-aware datetime is passed to naturalday() or naturaldate(), the date comparison should use 'today' in the datetime's timezone rather than the system's local date. Previously the timezone was stripped and the date compared against dt.date.today(), which could yield wrong results (e.g. returning 'tomorrow' when the local date in the given timezone is actually the same day). Fixes python-humanize#152
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## main #297 +/- ##
==========================================
+ Coverage 99.51% 99.52% +0.01%
==========================================
Files 11 11
Lines 831 851 +20
==========================================
+ Hits 827 847 +20
Misses 4 4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry.
|
Sorry, something went wrong.
|
Please see also similar PR #296, review it, and say which you think is better. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Fixes #152
When a tz-aware datetime is passed to naturalday() or naturaldate(), the functions now compute "today" in the datetime's timezone instead of using the system's local date.
For example, if the current UTC time is 2023-10-15 23:00 and you pass a datetime in AEDT (+11:00) where the local date is already Oct 16th, the comparison should use Oct 16th as "today" for that timezone. Previously the timezone was stripped and compared against the system local date, which gave wrong results when the tz-local date differed from the system date.
The fix checks whether the value is a tz-aware datetime and, if so, calls datetime.now(value.tzinfo).date() instead of date.today(). The existing behavior for naive datetimes and plain date objects is unchanged.
Test included using the exact scenarios from the issue.