本文整理匯總了Python中django.utils.formats.time_format方法的典型用法代碼示例。如果您正苦於以下問題:Python formats.time_format方法的具體用法?Python formats.time_format怎麽用?Python formats.time_format使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類django.utils.formats
的用法示例。
在下文中一共展示了formats.time_format方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: time
# 需要導入模塊: from django.utils import formats [as 別名]
# 或者: from django.utils.formats import time_format [as 別名]
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 ''
示例2: time
# 需要導入模塊: from django.utils import formats [as 別名]
# 或者: from django.utils.formats import time_format [as 別名]
def time(value, arg=None):
"""Format a time according to the given format."""
if value in (None, ''):
return ''
try:
return formats.time_format(value, arg)
except (AttributeError, TypeError):
try:
return time_format(value, arg)
except (AttributeError, TypeError):
return ''
示例3: time
# 需要導入模塊: from django.utils import formats [as 別名]
# 或者: from django.utils.formats import time_format [as 別名]
def time(value, arg=None):
"""Formats a time according to the given format."""
if value in (None, ''):
return ''
try:
return formats.time_format(value, arg)
except (AttributeError, TypeError):
try:
return time_format(value, arg)
except (AttributeError, TypeError):
return ''
示例4: _timeFormat
# 需要導入模塊: from django.utils import formats [as 別名]
# 或者: from django.utils.formats import time_format [as 別名]
def _timeFormat(when, formatStr):
"""
Format a single time, e.g. 10am
"""
if formatStr:
retval = _Formatter(when).format(formatStr)
else:
retval = formats.time_format(when)
return retval