#33879: timesince - wrong results for 11 months + several weeks
--------------------------------------+------------------------------------
Reporter: אורי | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Utilities | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Comment (by אורי):
Hi Claude,
I just looked at the algorithm and I found another bug:
If I add to my test this code:
{{{
user_21 = ActiveUserFactory()
user_21.profile.last_visit -= (relativedelta(years=2) -
relativedelta(days=1))
user_21.save_user_and_profile()
import re
print(re.sub(r'[^ -~]', lambda m: '\\u%04X' % ord(m[0]),
user_21.profile.last_visit_str))
user_22 = ActiveUserFactory()
user_22.profile.last_visit -= (relativedelta(years=2) -
relativedelta(days=2))
user_22.save_user_and_profile()
import re
print(re.sub(r'[^ -~]', lambda m: '\\u%04X' % ord(m[0]),
user_22.profile.last_visit_str))
}}}
Then, I get printed:
{{{
On 1 August 2020 (1\u00A0year, 12\u00A0months ago)
On 2 August 2020 (1\u00A0year, 12\u00A0months ago)
}}}
(In English)
So it returns 1 year, 12 months ago in both cases. Also I guess with 364
days it will return 12 months and not 1 year.
--
Ticket URL: <https://code.djangoproject.com/ticket/33879#comment:4>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/0107018255534e49-be314d9e-6987-4818-9bf7-b19e5fe3f07d-000000%40eu-central-1.amazonses.com.