Changeset 3077
- Timestamp:
- 06/03/06 20:03:48 (2 years ago)
- Files:
-
- django/trunk/django/contrib/humanize/templatetags/humanize.py (modified) (1 diff)
- django/trunk/docs/add_ons.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/django/contrib/humanize/templatetags/humanize.py
r3076 r3077 49 49 return value 50 50 register.filter(intword) 51 52 def apnumber(value): 53 """ 54 For numbers 1-9, returns the number spelled out. Otherwise, returns the 55 number. This follows Associated Press style. 56 """ 57 try: 58 value = int(value) 59 except ValueError: 60 return value 61 if not 0 < value < 10: 62 return value 63 return ('one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine')[value-1] 64 register.filter(apnumber) django/trunk/docs/add_ons.txt
r3076 r3077 54 54 in a template, and you'll have access to these filters: 55 55 56 ordinal 57 ------- 56 apnumber 57 -------- 58 58 59 Converts an integer to its ordinal as a string. 59 For numbers 1-9, returns the number spelled out. Otherwise, returns the 60 number. This follows Associated Press style. 60 61 61 62 Examples: 62 63 63 * ``1`` becomes ``' 1st'``.64 * ``2`` becomes ``' 2nd'``.65 * `` 3`` becomes ``'3rd'``.64 * ``1`` becomes ``'one'``. 65 * ``2`` becomes ``'two'``. 66 * ``10`` becomes ``10``. 66 67 67 68 You can pass in either an integer or a string representation of an integer. … … 94 95 95 96 Values up to 1000000000000000 (one quadrillion) are supported. 97 98 You can pass in either an integer or a string representation of an integer. 99 100 ordinal 101 ------- 102 103 Converts an integer to its ordinal as a string. 104 105 Examples: 106 107 * ``1`` becomes ``'1st'``. 108 * ``2`` becomes ``'2nd'``. 109 * ``3`` becomes ``'3rd'``. 96 110 97 111 You can pass in either an integer or a string representation of an integer.
