[Django] #30918: django.utils.timesince.timesince may return "0 minutes" ignoring the time_strings

5 views
Skip to first unread message

Django

unread,
Oct 27, 2019, 2:20:52 PM10/27/19
to django-...@googlegroups.com
#30918: django.utils.timesince.timesince may return "0 minutes" ignoring the
time_strings
---------------------------------------+---------------------------
Reporter: webtweakers | Owner: nobody
Type: Bug | Status: new
Component: Utilities | Version: 2.2
Severity: Normal | Keywords: timesince
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 0 |
---------------------------------------+---------------------------
In the code, when `delta` is `datetime.timedelta(0)` (line 66), the
condition `since <= 0` becomes true (line 70) and the function will return
this:
`return avoid_wrapping(gettext('0 minutes'))` (line 72)

This should probably be:
`return avoid_wrapping(time_strings['minute'] % 0)`

Or alternatively the condition could be changed to `since < 0`.

--
Ticket URL: <https://code.djangoproject.com/ticket/30918>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Oct 28, 2019, 3:26:11 AM10/28/19
to django-...@googlegroups.com
#30918: timesince() ignores time_strings argument for the same dates.
--------------------------------------+------------------------------------
Reporter: Bas Van Gaalen | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Utilities | Version: master
Severity: Normal | Resolution:
Keywords: timesince | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by felixxm):

* type: Bug => Cleanup/optimization
* version: 2.2 => master
* stage: Unreviewed => Accepted


Comment:

Thanks for this report. I'm not sure if it's an issue for any language but
I agree that we should use `time_strings['minute'] % 0`.

--
Ticket URL: <https://code.djangoproject.com/ticket/30918#comment:1>

Django

unread,
Oct 28, 2019, 4:58:23 AM10/28/19
to django-...@googlegroups.com
#30918: timesince() ignores time_strings argument for the same dates.
-------------------------------------+-------------------------------------
Reporter: Bas Van Gaalen | Owner: Hasan
Type: | Ramezani
Cleanup/optimization | Status: assigned

Component: Utilities | Version: master
Severity: Normal | Resolution:
Keywords: timesince | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Hasan Ramezani):

* status: new => assigned
* owner: nobody => Hasan Ramezani


--
Ticket URL: <https://code.djangoproject.com/ticket/30918#comment:2>

Django

unread,
Oct 28, 2019, 6:43:11 AM10/28/19
to django-...@googlegroups.com
#30918: timesince() ignores time_strings argument for the same dates.
-------------------------------------+-------------------------------------
Reporter: Bas Van Gaalen | Owner: Hasan
Type: | Ramezani
Cleanup/optimization | Status: assigned
Component: Utilities | Version: master
Severity: Normal | Resolution:
Keywords: timesince | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):

* has_patch: 0 => 1


Comment:

Note:
[https://docs.djangoproject.com/en/2.2/ref/contrib/humanize/#naturaltime
naturaltime] doesn't fall back to `timesince()` if the value is less than
a day old, moreover the `time_string` argument is not documented, so it's
not an issue in supported use cases. However, I agree that we can change
this for consistency because someone can use `timesince()/timeuntil()` in
custom filters.

--
Ticket URL: <https://code.djangoproject.com/ticket/30918#comment:3>

Django

unread,
Oct 28, 2019, 8:31:59 AM10/28/19
to django-...@googlegroups.com
#30918: timesince() ignores time_strings argument for the same dates.
-------------------------------------+-------------------------------------
Reporter: Bas Van Gaalen | Owner: Hasan
Type: | Ramezani
Cleanup/optimization | Status: closed
Component: Utilities | Version: master
Severity: Normal | Resolution: fixed

Keywords: timesince | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"52cb4190720f6ba9dd1cdb9cbd516733b1d4ca58" 52cb4190]:
{{{
#!CommitTicketReference repository=""
revision="52cb4190720f6ba9dd1cdb9cbd516733b1d4ca58"
Fixed #30918 -- Made timesince()/timeuntil() respect custom time strings
for future and the same datetimes.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/30918#comment:4>

Reply all
Reply to author
Forward
0 new messages