@library.filter
def datetime(value, kind=u'datetime', format=u'medium', tz=True):
 locale = get_current_babel_locale()
 if (type(value) is date):
  return format_date(value, format=format, locale=locale)
 if tz:
  value = localtime(value, (None if (tz is True) else tz))
 if (kind == u'datetime'):
  return format_datetime(value, format=format, locale=locale)
 elif (kind == u'date'):
  return format_date(value, format=format, locale=locale)
 elif (kind == u'time'):
  return format_time(value, format=format, locale=locale)
 else:
  raise ValueError((u'Unknown `datetime` kind: %r' % kind))

@ library . filter def datetime ( value , kind = u'datetime' , format = u'medium' , tz = True ) : locale = get_current_babel_locale ( ) if ( type ( value ) is date ) : return format_date ( value , format = format , locale = locale ) if tz : value = localtime ( value , ( None if ( tz is True ) else tz ) ) if ( kind == u'datetime' ) : return format_datetime ( value , format = format , locale = locale ) elif ( kind == u'date' ) : return format_date ( value , format = format , locale = locale ) elif ( kind == u'time' ) : return format_time ( value , format = format , locale = locale ) else : raise ValueError ( ( u'Unknown `datetime` kind: %r' % kind ) )
format a datetime for human consumption .