def date(value, arg=None):
"""Formats a date according to the given format."""
if value in (None, ''):
return ''
if arg is None:
arg = settings.DATE_FORMAT
try:
return formats.date_format(value, arg)
except AttributeError:
try:
return format(value, arg)
except AttributeError:
return ''
python类DATE_FORMAT的实例源码
def __str__(self):
return ugettext('%(title)s: %(start)s - %(end)s') % {
'title': self.title,
'start': date(self.start, django_settings.DATE_FORMAT),
'end': date(self.end, django_settings.DATE_FORMAT),
}
def __str__(self):
return ugettext("%(start)s to %(end)s") % {
'start': date(self.start, django_settings.DATE_FORMAT),
'end': date(self.end, django_settings.DATE_FORMAT)
}
def prevnext(target, calendar, period, fmt=None):
if fmt is None:
fmt = settings.DATE_FORMAT
context = {
'calendar': calendar,
'period': period,
'period_name': format(period.start, fmt),
'target': target,
}
return context
def __str__(self):
date_format = 'l, %s' % settings.DATE_FORMAT
return ugettext('Week: %(start)s-%(end)s') % {
'start': date_filter(self.start, date_format),
'end': date_filter(self.end, date_format),
}
def __str__(self):
date_format = 'l, %s' % settings.DATE_FORMAT
return ugettext('Day: %(start)s-%(end)s') % {
'start': date_filter(self.start, date_format),
'end': date_filter(self.end, date_format),
}
def date(value, arg=None):
"""Formats a date according to the given format."""
if value in (None, ''):
return ''
if arg is None:
arg = settings.DATE_FORMAT
try:
return formats.date_format(value, arg)
except AttributeError:
try:
return format(value, arg)
except AttributeError:
return ''
def date(value, arg=None):
"""Formats a date according to the given format."""
if value in (None, ''):
return ''
if arg is None:
arg = settings.DATE_FORMAT
try:
return formats.date_format(value, arg)
except AttributeError:
try:
return format(value, arg)
except AttributeError:
return ''
def date(value, arg=None):
"""Formats a date according to the given format."""
if value in (None, ''):
return ''
if arg is None:
arg = settings.DATE_FORMAT
try:
return formats.date_format(value, arg)
except AttributeError:
try:
return format(value, arg)
except AttributeError:
return ''