Code

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#13541 closed (invalid)

Proposition to add a humanized date diff template filter

Reported by: batiste 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: UI/UX:

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.

Attachments (0)

Change History (8)

comment:1 Changed 4 years ago by batiste

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

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

comment:2 Changed 4 years ago by batiste

  • Summary changed from Proposition to add for a smart i18n date diff filter in Django to Proposition to add a i18n date diff template filter in Django

comment:3 Changed 4 years ago by batiste

  • Summary changed from Proposition to add a i18n date diff template filter in Django to Proposition to add a humanized date diff template filter

comment:4 Changed 4 years ago by batiste

Here is a quite good javascript implementation:

http://timeago.yarp.com/

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

comment:5 Changed 4 years ago by jezdez

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

comment:6 Changed 4 years ago by batiste

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 Changed 4 years ago by russellm

  • Resolution set to invalid
  • Status changed from new to closed

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 Changed 4 years ago by batiste

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

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.