def time(value, arg=None):
"""Formats a time according to the given format."""
if value in (None, ''):
return ''
if arg is None:
arg = settings.TIME_FORMAT
try:
return formats.time_format(value, arg)
except AttributeError:
try:
return time_format(value, arg)
except AttributeError:
return ''
python类TIME_FORMAT的实例源码
def timeformat(data):
try:
return data.strftime(settings.TIME_FORMAT)
# print(data.strftime(settings.TIME_FORMAT))
# return "ddd"
except:
return ""
def __init__(self, format=None, *args, **kwargs):
if format is None:
format = settings.TIME_FORMAT
template = '{{ value|date:"%s"|default:default }}' % format
super(TimeColumn, self).__init__(template_code=template, *args, **kwargs)
def __init__(self, format=None, *args, **kwargs):
if format is None:
format = settings.TIME_FORMAT
template = '{{ value|date:"%s"|default:default }}' % format
super(TimeColumn, self).__init__(template_code=template, *args, **kwargs)
def time(value, arg=None):
"""Formats a time according to the given format."""
if value in (None, ''):
return ''
if arg is None:
arg = settings.TIME_FORMAT
try:
return formats.time_format(value, arg)
except AttributeError:
try:
return time_format(value, arg)
except AttributeError:
return ''
def time(value, arg=None):
"""Formats a time according to the given format."""
if value in (None, ''):
return ''
if arg is None:
arg = settings.TIME_FORMAT
try:
return formats.time_format(value, arg)
except AttributeError:
try:
return time_format(value, arg)
except AttributeError:
return ''
def time(value, arg=None):
"""Formats a time according to the given format."""
if value in (None, ''):
return ''
if arg is None:
arg = settings.TIME_FORMAT
try:
return formats.time_format(value, arg)
except AttributeError:
try:
return time_format(value, arg)
except AttributeError:
return ''