Opened 15 years ago

Closed 15 years ago

Last modified 14 years ago

#13541 closed (invalid)

Proposition to add a humanized date diff template filter

Reported by: Batiste Bieler Owned by: nobody
Component: Contrib apps Version: 1.1
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Hi,

I have been using this filter on some projects. I believe that it's a common need when developing web apps with social feeds. Here is an example implementation:

http://github.com/batiste/date-diff/blob/master/date_diff.py

Originally it was a Django snippets from here : http://djangosnippets.org/snippets/1409/ and http://djangosnippets.org/snippets/1347/

I haven't quite make my mind yet around the idea of doing that using javascript like here:

http://ejohn.org/blog/javascript-pretty-date/

The javascript implementation would have the advantage of exposing a formated date for micro formats.

Change History (8)

comment:1 by Batiste Bieler, 15 years ago

Javascript would also the advantage of easing the cache of the content without compromising the accuracy of the fuzzy diff.

comment:2 by Batiste Bieler, 15 years ago

Summary: Proposition to add for a smart i18n date diff filter in DjangoProposition to add a i18n date diff template filter in Django

comment:3 by Batiste Bieler, 15 years ago

Summary: Proposition to add a i18n date diff template filter in DjangoProposition to add a humanized date diff template filter

comment:4 by Batiste Bieler, 15 years ago

Here is a quite good javascript implementation:

http://timeago.yarp.com/

http://github.com/rmm5t/jquery-timeago

comment:5 by Jannis Leidel, 15 years ago

I don't know, but how does the Python implementation differ to the timesince filter (source:django/trunk/django/utils/timesince.py)?

comment:6 by Batiste Bieler, 15 years ago

I wasn't aware of the timesince filter. Those 2 filters a definitely very similar. I thought I was filling a gap by providing this new filter but it's not the case.

Do we have some tests for timesince? Maybe I could propose a patch to improve this filter output?

comment:7 by Russell Keith-Magee, 15 years ago

Resolution: invalid
Status: newclosed

As jezdez notes: we have timesince, and it's already got internationalized output. Tests are in regressiontests/templates/filters and regressiontests/utils/timesince.

If you want to add a specific feature to the timesince filter, open a new ticket requesting that specific feature.

As for a javascript implementation; I'm not convinced that's a good idea, or if it is, that it's a good idea for Django (which aims to remain client-side neutral).

comment:8 by Batiste Bieler, 14 years ago

I renamed the filter in fuzzy_date because it describe it in a more appropriate way. And now it also handle future dates:

http://github.com/batiste/date-diff

I believe the use case is a little more different than with the timeslice. Timeslice provide a quite precise time difference. And it doesn't work for a date in the future (although it should be easy to add).

I am not gonna argue more about this feature if nobody else need something like that.

Cheers,
Batiste

Note: See TracTickets for help on using tickets.
Back to Top