本文整理汇总了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