docs: def to_datetime(dt, tzinfo=None, format=None):
      """
      Convert a date or time to datetime with tzinfo
      """
      if not dt:
          return dt
      
      tz = pick_timezone(tzinfo, __timezone__)
      
      if isinstance(dt, (str, unicode)):
          if not format:
              formats = DEFAULT_DATETIME_INPUT_FORMATS
          else:
              formats = list(format)
          d = None
          for fmt in formats:
              try:
                  d = datetime.strptime(dt, fmt)
              except ValueError:
                  continue
          if not d:
              return None
          d = d.replace(tzinfo=tz)
      else:
          d = datetime(getattr(dt, 'year', 1970), getattr(dt, 'month', 1),
              getattr(dt, 'day', 1), getattr(dt, 'hour', 0), getattr(dt, 'minute', 0),
              getattr(dt, 'second', 0), getattr(dt, 'microsecond', 0))
          if not getattr(dt, 'tzinfo', None):
              d = d.replace(tzinfo=tz)
          else:
              d = d.replace(tzinfo=dt.tzinfo)
      return to_timezone(d, tzinfo)