Hi, Lately I discovered some inaccuracy bugs in timesince (and timeuntil), and I created a ticket (#33879 <https://code.djangoproject.com/ticket/33879>). In short, the problems are when calculating a year minus one week, 2 weeks, one day etc. and also 2 years minus one or 2 days. In all such cases, Django's implementation of timesince is inaccurate, in some cases resulting in "1 year, 12 months" (for 2 years minus one or 2 days) or adding a week (for a year minus one or 2 weeks). I read the code of Django's timesince implementation and it's quite long, and I searched and found that python-dateutil already have such methods, which is possible to calculate exactly the number of days between two dates like this:
*from dateutil.relativedelta import relativedeltadiff = relativedelta(date2, date1)years = diff.yearsmonths = diff.monthsweeks = diff.days // 7days = diff.days - weeks * 7 # ("**diff.days % 7" will also work here)* This calculates exactly the number of years, months, weeks and days and not an approximation like Django's implementation. And python-dateutil is stable and I think exists even before Django. I recently started using Django's timesince function in my own website, and I like the way it's translated (currently only to English and Hebrew). Do you think it's worth using python-dateutil in the Django implementation of timesince and timeuntil? Of course, I can also implement my own version of timesince which uses python-dateutil and doesn't use Django. But since timesince and timeuntil are built-in tags in Django, I guess many websites are using them. Isn't it better to use a more precise implementation and avoid something like "1 year, 12 months"? Thanks, Uri Rodberg, Speedy Net אורי u...@speedy.net -- You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-developers+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/CABD5YeEC_o%2BwQVF8pj3Kat57MXfX071LT0rZAq2XipFFCK%3DFBQ%40mail.gmail.com.