PageRenderTime 92ms CodeModel.GetById 85ms RepoModel.GetById 0ms app.codeStats 0ms

/docs/ref/contrib/humanize.txt

https://code.google.com/p/mango-py/
Plain Text | 98 lines | 64 code | 34 blank | 0 comment | 0 complexity | 476abdd0ad2d07c8c40858b20b32e5b6 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. ========================
  2. django.contrib.humanize
  3. ========================
  4. .. module:: django.contrib.humanize
  5. :synopsis: A set of Django template filters useful for adding a "human
  6. touch" to data.
  7. A set of Django template filters useful for adding a "human touch" to data.
  8. To activate these filters, add ``'django.contrib.humanize'`` to your
  9. :setting:`INSTALLED_APPS` setting. Once you've done that, use
  10. ``{% load humanize %}`` in a template, and you'll have access to the following
  11. filters.
  12. .. templatefilter:: apnumber
  13. apnumber
  14. --------
  15. For numbers 1-9, returns the number spelled out. Otherwise, returns the
  16. number. This follows Associated Press style.
  17. Examples:
  18. * ``1`` becomes ``one``.
  19. * ``2`` becomes ``two``.
  20. * ``10`` becomes ``10``.
  21. You can pass in either an integer or a string representation of an integer.
  22. .. templatefilter:: intcomma
  23. intcomma
  24. --------
  25. Converts an integer to a string containing commas every three digits.
  26. Examples:
  27. * ``4500`` becomes ``4,500``.
  28. * ``45000`` becomes ``45,000``.
  29. * ``450000`` becomes ``450,000``.
  30. * ``4500000`` becomes ``4,500,000``.
  31. You can pass in either an integer or a string representation of an integer.
  32. .. templatefilter:: intword
  33. intword
  34. -------
  35. Converts a large integer to a friendly text representation. Works best for
  36. numbers over 1 million.
  37. Examples:
  38. * ``1000000`` becomes ``1.0 million``.
  39. * ``1200000`` becomes ``1.2 million``.
  40. * ``1200000000`` becomes ``1.2 billion``.
  41. Values up to 1000000000000000 (one quadrillion) are supported.
  42. You can pass in either an integer or a string representation of an integer.
  43. .. templatefilter:: naturalday
  44. naturalday
  45. ----------
  46. For dates that are the current day or within one day, return "today",
  47. "tomorrow" or "yesterday", as appropriate. Otherwise, format the date using
  48. the passed in format string.
  49. **Argument:** Date formatting string as described in the :tfilter:`date` tag.
  50. Examples (when 'today' is 17 Feb 2007):
  51. * ``16 Feb 2007`` becomes ``yesterday``.
  52. * ``17 Feb 2007`` becomes ``today``.
  53. * ``18 Feb 2007`` becomes ``tomorrow``.
  54. * Any other day is formatted according to given argument or the
  55. :setting:`DATE_FORMAT` setting if no argument is given.
  56. .. templatefilter:: ordinal
  57. ordinal
  58. -------
  59. Converts an integer to its ordinal as a string.
  60. Examples:
  61. * ``1`` becomes ``1st``.
  62. * ``2`` becomes ``2nd``.
  63. * ``3`` becomes ``3rd``.
  64. You can pass in either an integer or a string representation of an integer.