MCPcopy
hub / github.com/django/django / date_format

Function date_format

django/utils/formats.py:147–157  ·  view source on GitHub ↗

Format a datetime.date or datetime.datetime object using a localizable format. If use_l10n is provided and is not None, that will force the value to be localized (or not), otherwise it's always localized.

(value, format=None, use_l10n=None)

Source from the content-addressed store, hash-verified

145
146
147def date_format(value, format=None, use_l10n=None):
148 """
149 Format a datetime.date or datetime.datetime object using a
150 localizable format.
151
152 If use_l10n is provided and is not None, that will force the value to
153 be localized (or not), otherwise it's always localized.
154 """
155 return dateformat.format(
156 value, get_format(format or "DATE_FORMAT", use_l10n=use_l10n)
157 )
158
159
160def time_format(value, format=None, use_l10n=None):

Callers 7

test_l10n_enabledMethod · 0.90
test_sub_localesMethod · 0.90
test_now02Method · 0.90
test_now04Method · 0.90
localizeFunction · 0.85

Calls 2

get_formatFunction · 0.85
formatMethod · 0.45

Tested by 6

test_l10n_enabledMethod · 0.72
test_sub_localesMethod · 0.72
test_now02Method · 0.72
test_now04Method · 0.72