Ticket #18608: 18608.diff

File 18608.diff, 1.9 KB (added by Claude Paroz, 12 years ago)
  • django/contrib/humanize/templatetags/humanize.py

    diff --git a/django/contrib/humanize/templatetags/humanize.py b/django/contrib/humanize/templatetags/humanize.py
    index 7a2e514..1398b43 100644
    a b def naturaltime(value):  
    184184        if delta.days != 0:
    185185            return pgettext(
    186186                'naturaltime', '%(delta)s ago'
    187             ) % {'delta': defaultfilters.timesince(value)}
     187            ) % {'delta': defaultfilters.timesince(value, now)}
    188188        elif delta.seconds == 0:
    189189            return _('now')
    190190        elif delta.seconds < 60:
    def naturaltime(value):  
    206206        if delta.days != 0:
    207207            return pgettext(
    208208                'naturaltime', '%(delta)s from now'
    209             ) % {'delta': defaultfilters.timeuntil(value)}
     209            ) % {'delta': defaultfilters.timeuntil(value, now)}
    210210        elif delta.seconds == 0:
    211211            return _('now')
    212212        elif delta.seconds < 60:
  • django/contrib/humanize/tests.py

    diff --git a/django/contrib/humanize/tests.py b/django/contrib/humanize/tests.py
    index ecf4b83..a2b141e 100644
    a b class HumanizeTests(TestCase):  
    130130            def utcoffset(self, dt):
    131131                return None
    132132        # we're going to mock datetime.datetime, so use a fixed datetime
    133         now = datetime.datetime(2011, 8, 15)
     133        now = datetime.datetime(2011, 8, 15, 1, 23)
    134134        test_list = [
    135135            now,
    136136            now - datetime.timedelta(seconds=1),
    class HumanizeTests(TestCase):  
    191191        orig_humanize_datetime = humanize.datetime
    192192        orig_timesince_datetime = timesince.datetime
    193193        humanize.datetime = MockDateTime
    194         timesince.datetime = new.module(b"mock_datetime")
    195         timesince.datetime.datetime = MockDateTime
    196194
    197195        try:
    198196            self.humanize_tester(test_list, result_list, 'naturaltime')
Back to Top