diff --git a/django/contrib/humanize/templatetags/humanize.py b/django/contrib/humanize/templatetags/humanize.py
index cfa93fe..6a3ecd5 100644
|
a
|
b
|
from django.utils.translation import ungettext, ugettext as _
|
| 2 | 2 | from django.utils.encoding import force_unicode |
| 3 | 3 | from django import template |
| 4 | 4 | from django.template import defaultfilters |
| 5 | | from datetime import date |
| | 5 | from datetime import date |
| 6 | 6 | import re |
| 7 | 7 | |
| 8 | 8 | register = template.Library() |
| … |
… |
def naturalday(value, arg=None):
|
| 100 | 100 | return _(u'yesterday') |
| 101 | 101 | return defaultfilters.date(value, arg) |
| 102 | 102 | register.filter(naturalday) |
| | 103 | |
| | 104 | |
| | 105 | |
| | 106 | |
| | 107 | |
| | 108 | |
| | 109 | |
| | 110 | |
| | 111 | |
| | 112 | |
| | 113 | |
| | 114 | |
| | 115 | |
| | 116 | |
| | 117 | |
| | 118 | |
| | 119 | |
| | 120 | |
| | 121 | |
| | 122 | |
| | 123 | |
| | 124 | |
| | 125 | |
| | 126 | |
| | 127 | |
| | 128 | |
| | 129 | |
| | 130 | |
| | 131 | |
| | 132 | |
| | 133 | |
| | 134 | |
diff --git a/docs/ref/contrib/humanize.txt b/docs/ref/contrib/humanize.txt
index ef48f48..a9a2c17 100644
|
a
|
b
|
Examples (when 'today' is 17 Feb 2007):
|
| 82 | 82 | * Any other day is formatted according to given argument or the |
| 83 | 83 | :setting:`DATE_FORMAT` setting if no argument is given. |
| 84 | 84 | |
| | 85 | |
| | 86 | |
| | 87 | |
| | 88 | |
| | 89 | |
| | 90 | |
| | 91 | |
| | 92 | |
| | 93 | |
| | 94 | |
| | 95 | |
| | 96 | |
| | 97 | |
| | 98 | |
| | 99 | |
| | 100 | |
| | 101 | |
| | 102 | |
| | 103 | |
| | 104 | |
| | 105 | |
| | 106 | |
| | 107 | |
| 85 | 108 | .. templatefilter:: ordinal |
| 86 | 109 | |
| 87 | 110 | ordinal |
diff --git a/tests/regressiontests/humanize/tests.py b/tests/regressiontests/humanize/tests.py
index 7eeaaee..c53060b 100644
|
a
|
b
|
|
| 1 | | from datetime import timedelta, date |
| | 1 | from datetime import timedelta, date |
| 2 | 2 | |
| 3 | 3 | from django.template import Template, Context, add_to_builtins |
| 4 | 4 | from django.utils import unittest |
| … |
… |
class HumanizeTests(unittest.TestCase):
|
| 60 | 60 | |
| 61 | 61 | def test_naturalday(self): |
| 62 | 62 | from django.template import defaultfilters |
| 63 | | today = date.today() |
| | 63 | today = date() |
| 64 | 64 | yesterday = today - timedelta(days=1) |
| 65 | 65 | tomorrow = today + timedelta(days=1) |
| 66 | 66 | someday = today - timedelta(days=10) |
| … |
… |
class HumanizeTests(unittest.TestCase):
|
| 72 | 72 | someday_result, u"I'm not a date value", None) |
| 73 | 73 | self.humanize_tester(test_list, result_list, 'naturalday') |
| 74 | 74 | |
| | 75 | |
| | 76 | |
| | 77 | |
| | 78 | |
| | 79 | |
| | 80 | |
| | 81 | |
| | 82 | |
| | 83 | |
| | 84 | |
| | 85 | |
| | 86 | |
| | 87 | |
| | 88 | |
| | 89 | |
| | 90 | |
| | 91 | |
| | 92 | |
| | 93 | |
| | 94 | |
| | 95 | |
| | 96 | |
| | 97 | |
| | 98 | |
| | 99 | |
| | 100 | |
| 75 | 101 | if __name__ == '__main__': |
| 76 | 102 | unittest.main() |
| 77 | 103 | |