From ea248f0107eb3bed5a4a0fb65d6065e5691bea0a Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Fri, 22 Apr 2011 12:02:47 +0000 Subject: Fixed #12771 -- Added naturaltime filter to humanize contrib app. Thanks, phinpho, djansoft and xtrqt. git-svn-id: http://code.djangoproject.com/svn/django/trunk@16071 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- docs/ref/contrib/humanize.txt | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'docs') diff --git a/docs/ref/contrib/humanize.txt b/docs/ref/contrib/humanize.txt index ef48f48fcc..f7afb9c5e8 100644 --- a/docs/ref/contrib/humanize.txt +++ b/docs/ref/contrib/humanize.txt @@ -82,6 +82,31 @@ Examples (when 'today' is 17 Feb 2007): * Any other day is formatted according to given argument or the :setting:`DATE_FORMAT` setting if no argument is given. +.. templatefilter:: naturaltime + +naturaltime +----------- + +.. versionadded:: 1.4 + +For date and time values shows how many seconds, minutes or hours ago compared +to current timestamp returns representing string. Otherwise, it behaves like +:tfilter:`naturaldate`, so it can also take string argument for date formating. + +**Argument:** Date formatting string as described in the :tfilter:`date` tag. + +Examples (when 'now' is 17 Feb 2007 16:30:00): + + * ``17 Feb 2007 16:30:00`` becomes ``now``. + * ``17 Feb 2007 16:29:31`` becomes ``29 seconds ago``. + * ``17 Feb 2007 16:29:00`` becomes ``a minute ago``. + * ``17 Feb 2007 16:25:35`` becomes ``4 minutes ago``. + * ``17 Feb 2007 15:30:29`` becomes ``an hours ago``. + * ``17 Feb 2007 13:31:29`` becomes ``2 hours ago``. + * ``16 Feb 2007 13:31:29`` becomes ``yesterday``. + * Any other day is formatted according to given argument or the + :setting:`DATE_FORMAT` setting if no argument is given. + .. templatefilter:: ordinal ordinal -- cgit v1.3