Skip to content

Instantly share code, notes, and snippets.

@claudep
Created July 10, 2012 18:43
Show Gist options
  • Save claudep/3085452 to your computer and use it in GitHub Desktop.
Save claudep/3085452 to your computer and use it in GitHub Desktop.
diff --git a/django/contrib/humanize/templatetags/humanize.py b/django/contrib/humanize/templatetags/humanize.py
index 7a2e514..1398b43 100644
--- a/django/contrib/humanize/templatetags/humanize.py
+++ b/django/contrib/humanize/templatetags/humanize.py
@@ -184,7 +184,7 @@ def naturaltime(value):
if delta.days != 0:
return pgettext(
'naturaltime', '%(delta)s ago'
- ) % {'delta': defaultfilters.timesince(value)}
+ ) % {'delta': defaultfilters.timesince(value, now)}
elif delta.seconds == 0:
return _('now')
elif delta.seconds < 60:
@@ -206,7 +206,7 @@ def naturaltime(value):
if delta.days != 0:
return pgettext(
'naturaltime', '%(delta)s from now'
- ) % {'delta': defaultfilters.timeuntil(value)}
+ ) % {'delta': defaultfilters.timeuntil(value, now)}
elif delta.seconds == 0:
return _('now')
elif delta.seconds < 60:
diff --git a/django/contrib/humanize/tests.py b/django/contrib/humanize/tests.py
index ecf4b83..a2b141e 100644
--- a/django/contrib/humanize/tests.py
+++ b/django/contrib/humanize/tests.py
@@ -130,7 +130,7 @@ class HumanizeTests(TestCase):
def utcoffset(self, dt):
return None
# we're going to mock datetime.datetime, so use a fixed datetime
- now = datetime.datetime(2011, 8, 15)
+ now = datetime.datetime(2011, 8, 15, 1, 23)
test_list = [
now,
now - datetime.timedelta(seconds=1),
@@ -191,8 +191,6 @@ class HumanizeTests(TestCase):
orig_humanize_datetime = humanize.datetime
orig_timesince_datetime = timesince.datetime
humanize.datetime = MockDateTime
- timesince.datetime = new.module(b"mock_datetime")
- timesince.datetime.datetime = MockDateTime
try:
self.humanize_tester(test_list, result_list, 'naturaltime')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment