﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
23340	naturaltime documentation doesn't match behavior	Zach Borboa	blackguest	"The documentation for django.contrib.humanize.templatetags.humanize.naturaltime doesn't match it's behavior.

Test:
{{{
from collections import OrderedDict
from datetime import datetime

from django.contrib.humanize.templatetags.humanize import naturaltime


# From the documentation.
times = OrderedDict()
times['17 Feb 2007 16:30:00'] = 'now'
times['17 Feb 2007 16:29:31'] = '29 seconds ago'
times['17 Feb 2007 16:29:00'] = 'a minute ago'
times['17 Feb 2007 16:25:35'] = '4 minutes ago'
times['17 Feb 2007 15:30:29'] = 'an hour ago'
times['17 Feb 2007 13:31:29'] = '2 hours ago'
times['16 Feb 2007 13:31:29'] = '1 day, 3 hours ago'
times['17 Feb 2007 16:30:30'] = '29 seconds from now'
times['17 Feb 2007 16:31:00'] = 'a minute from now'
times['17 Feb 2007 16:34:35'] = '4 minutes from now'
times['17 Feb 2007 16:30:29'] = 'an hour from now'
times['17 Feb 2007 18:31:29'] = '2 hours from now'
times['18 Feb 2007 16:31:29'] = '1 day from now'
times['26 Feb 2007 18:31:29'] = '1 week, 2 days from now'

time_format = '%d %b %Y %H:%M:%S'
now = datetime.strptime('17 Feb 2007 16:30:00', time_format)
for time, expected_time in times.iteritems():
    time = datetime.strptime(time, time_format)
    got = naturaltime(time).replace(u'\xa0', u' ')
    print '   {0}'.format(now)
    print '   {0}'.format(time)
    if got != expected_time:
        print '-- {0}'.format(got)
        print '++ {0}'.format(expected_time)
    else:
        print 'OK'
    print '-' * 80

}}}

Modified ""now"".
{{{
diff --git a/django/contrib/humanize/templatetags/humanize.py b/django/contrib/humanize/templatetags/humanize.py
index 993b728..7e28b04 100644
--- a/django/contrib/humanize/templatetags/humanize.py
+++ b/django/contrib/humanize/templatetags/humanize.py
@@ -193,7 +193,7 @@ def naturaltime(value):
     if not isinstance(value, date):  # datetime is a subclass of date
         return value
 
-    now = datetime.now(utc if is_aware(value) else None)
+    now = datetime.strptime('17 Feb 2007 16:30:00', '%d %b %Y %H:%M:%S') # TESTING
     if value < now:
         delta = now - value
         if delta.days != 0:

}}}

Output:
{{{
   2007-02-17 16:30:00
   2007-02-17 16:30:00
OK
--------------------------------------------------------------------------------
   2007-02-17 16:30:00
   2007-02-17 16:29:31
OK
--------------------------------------------------------------------------------
   2007-02-17 16:30:00
   2007-02-17 16:29:00
OK
--------------------------------------------------------------------------------
   2007-02-17 16:30:00
   2007-02-17 16:25:35
OK
--------------------------------------------------------------------------------
   2007-02-17 16:30:00
   2007-02-17 15:30:29
-- 59 minutes ago
++ an hour ago
--------------------------------------------------------------------------------
   2007-02-17 16:30:00
   2007-02-17 13:31:29
OK
--------------------------------------------------------------------------------
   2007-02-17 16:30:00
   2007-02-16 13:31:29
-- 1 day, 2 hours ago
++ 1 day, 3 hours ago
--------------------------------------------------------------------------------
   2007-02-17 16:30:00
   2007-02-17 16:30:30
-- 30 seconds from now
++ 29 seconds from now
--------------------------------------------------------------------------------
   2007-02-17 16:30:00
   2007-02-17 16:31:00
OK
--------------------------------------------------------------------------------
   2007-02-17 16:30:00
   2007-02-17 16:34:35
OK
--------------------------------------------------------------------------------
   2007-02-17 16:30:00
   2007-02-17 16:30:29
-- 29 seconds from now
++ an hour from now
--------------------------------------------------------------------------------
   2007-02-17 16:30:00
   2007-02-17 18:31:29
OK
--------------------------------------------------------------------------------
   2007-02-17 16:30:00
   2007-02-18 16:31:29
OK
--------------------------------------------------------------------------------
   2007-02-17 16:30:00
   2007-02-26 18:31:29
OK
--------------------------------------------------------------------------------
}}}"	Bug	closed	contrib.humanize	dev	Normal	fixed	afraid-to-commit		Accepted	1	0	0	0	1	0
