MCPcopy
hub / github.com/django/django / date

Function date

django/template/defaultfilters.py:785–795  ·  view source on GitHub ↗

Format a date according to the given format.

(value, arg=None)

Source from the content-addressed store, hash-verified

783
784@register.filter(expects_localtime=True, is_safe=False)
785def date(value, arg=None):
786 """Format a date according to the given format."""
787 if value in (None, ""):
788 return ""
789 try:
790 return formats.date_format(value, arg)
791 except AttributeError:
792 try:
793 return format(value, arg)
794 except AttributeError:
795 return ""
796
797
798@register.filter(expects_localtime=True, is_safe=False)

Callers 15

test_dateMethod · 0.90
test_no_argsMethod · 0.90
naturaldayFunction · 0.85
valueMethod · 0.85
renderMethod · 0.85
check_pr.pyFile · 0.85
setUpTestDataMethod · 0.85
test_inheritanceMethod · 0.85
setUpTestDataMethod · 0.85
test_parse_dateMethod · 0.85
test_dateMethod · 0.85

Calls 1

formatFunction · 0.90

Tested by 15

test_dateMethod · 0.72
test_no_argsMethod · 0.72
setUpTestDataMethod · 0.68
test_inheritanceMethod · 0.68
setUpTestDataMethod · 0.68
test_parse_dateMethod · 0.68
test_dateMethod · 0.68
test_S_formatMethod · 0.68