parameters: (env, value, lang_code=False, date_format=False)
return_statement: return babel.dates.format_date(value, format=date_format, locale=locale)
docstring: Formats the date in a given format.
  
          :param env: an environment.
          :param date, datetime or string value: the date to format.
          :param string lang_code: the lang code, if not specified it is extracted from the
              environment context.
          :param string date_format: the format or the date (LDML format), if not specified the
              default format of the lang.
          :return: date formatted in the specified format.
          :rtype: string
docstring_summary: Formats the date in a given format.
docstring_tokens: Formats the date in a given format .
function: def format_date(env, value, lang_code=False, date_format=False):
      '''
          Formats the date in a given format.
  
          :param env: an environment.
          :param date, datetime or string value: the date to format.
          :param string lang_code: the lang code, if not specified it is extracted from the
              environment context.
          :param string date_format: the format or the date (LDML format), if not specified the
              default format of the lang.
          :return: date formatted in the specified format.
          :rtype: string
      '''
      if not value:
          return ''
      if isinstance(value, str):
          if len(value) < DATE_LENGTH:
              return ''
          if len(value) > DATE_LENGTH:
              # a datetime, convert to correct timezone
              value = odoo.fields.Datetime.from_string(value)
              value = odoo.fields.Datetime.context_timestamp(env['res.lang'], value)
          else:
              value = odoo.fields.Datetime.from_string(value)
  
      lang = get_lang(env, lang_code)
      locale = babel_locale_parse(lang.code)
      if not date_format:
          date_format = posix_to_ldml(lang.date_format, locale=locale)
  
      return babel.dates.format_date(value, format=date_format, locale=locale)
function_tokens: def format_date ( env , value , lang_code = False , date_format = False ) : if not value : return '' if isinstance ( value , str ) : if len ( value ) < DATE_LENGTH : return '' if len ( value ) > DATE_LENGTH : # a datetime, convert to correct timezone value = odoo . fields . Datetime . from_string ( value ) value = odoo . fields . Datetime . context_timestamp ( env [ 'res.lang' ] , value ) else : value = odoo . fields . Datetime . from_string ( value ) lang = get_lang ( env , lang_code ) locale = babel_locale_parse ( lang . code ) if not date_format : date_format = posix_to_ldml ( lang . date_format , locale = locale ) return babel . dates . format_date ( value , format = date_format , locale = locale )