code: def instance(
      dt, tz=UTC  # type: _datetime.datetime  # type: Union[str, _Timezone, None]
  ):  # type: (...) -> DateTime
      
      if not isinstance(dt, _datetime.datetime):
          raise ValueError("instance() only accepts datetime objects.")
  
      if isinstance(dt, DateTime):
          return dt
  
      tz = dt.tzinfo or tz
  
      # Checking for pytz/tzinfo
      if isinstance(tz, _datetime.tzinfo) and not isinstance(tz, _Timezone):
          # pytz
          if hasattr(tz, "localize") and tz.zone:
              tz = tz.zone
          else:
              # We have no sure way to figure out
              # the timezone name, we fallback
              # on a fixed offset
              tz = tz.utcoffset(dt).total_seconds() / 3600
  
      return datetime(
          dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second, dt.microsecond, tz=tz
      )
docs: Create a DateTime instance from a datetime one.