code: def iso_time_string(val, show_tzinfo=False):
      
      if not val:
          return ""
      if isinstance(val, six.string_types):
          dt = _parse_datetime_string(val)
      else:
          dt = val
      if not isinstance(dt, datetime.datetime):
          dt = datetime.datetime.fromordinal(dt.toordinal())
      has_tz = (dt.tzinfo is not None)
      if show_tzinfo and has_tz:
          # Need to remove the colon in the TZ portion
          ret = "".join(dt.isoformat().rsplit(":", 1))
      elif show_tzinfo and not has_tz:
          ret = "%s+0000" % dt.isoformat().split(".")[0]
      elif not show_tzinfo and has_tz:
          ret = dt.isoformat()[:-6]
      elif not show_tzinfo and not has_tz:
          ret = dt.isoformat().split(".")[0]
      return ret
docs: Takes either a date, datetime or a string, and returns the standard ISO
      formatted string for that date/time, with any fractional second portion
      removed.