Add Django-1.2.1
[frozenviper.git] / Django-1.2.1 / docs / ref / contrib / humanize.txt
blob07a62a7fbe863b9ed0019f4061e96aeb25b479c0
1 .. _ref-contrib-humanize:
3 ========================
4 django.contrib.humanize
5 ========================
7 .. module:: django.contrib.humanize
8    :synopsis: A set of Django template filters useful for adding a "human
9               touch" to data.
11 A set of Django template filters useful for adding a "human touch" to data.
13 To activate these filters, add ``'django.contrib.humanize'`` to your
14 :setting:`INSTALLED_APPS` setting. Once you've done that, use
15 ``{% load humanize %}`` in a template, and you'll have access to these filters:
17 apnumber
18 --------
20 For numbers 1-9, returns the number spelled out. Otherwise, returns the
21 number. This follows Associated Press style.
23 Examples:
25     * ``1`` becomes ``'one'``.
26     * ``2`` becomes ``'two'``.
27     * ``10`` becomes ``10``.
29 You can pass in either an integer or a string representation of an integer.
31 intcomma
32 --------
34 Converts an integer to a string containing commas every three digits.
36 Examples:
38     * ``4500`` becomes ``'4,500'``.
39     * ``45000`` becomes ``'45,000'``.
40     * ``450000`` becomes ``'450,000'``.
41     * ``4500000`` becomes ``'4,500,000'``.
43 You can pass in either an integer or a string representation of an integer.
45 intword
46 -------
48 Converts a large integer to a friendly text representation. Works best for
49 numbers over 1 million.
51 Examples:
53     * ``1000000`` becomes ``'1.0 million'``.
54     * ``1200000`` becomes ``'1.2 million'``.
55     * ``1200000000`` becomes ``'1.2 billion'``.
57 Values up to 1000000000000000 (one quadrillion) are supported.
59 You can pass in either an integer or a string representation of an integer.
61 ordinal
62 -------
64 Converts an integer to its ordinal as a string.
66 Examples:
68     * ``1`` becomes ``'1st'``.
69     * ``2`` becomes ``'2nd'``.
70     * ``3`` becomes ``'3rd'``.
72 You can pass in either an integer or a string representation of an integer.
74 naturalday
75 ----------
77 .. versionadded:: 1.0
79 For dates that are the current day or within one day, return "today",
80 "tomorrow" or "yesterday", as appropriate. Otherwise, format the date using
81 the passed in format string.
83 **Argument:** Date formatting string as described in the :ttag:`now` tag.
85 Examples (when 'today' is 17 Feb 2007):
87     * ``16 Feb 2007`` becomes ``yesterday``.
88     * ``17 Feb 2007`` becomes ``today``.
89     * ``18 Feb 2007`` becomes ``tomorrow``.
90     * Any other day is formatted according to given argument or the
91       :setting:`DATE_FORMAT` setting if no argument is given.