code: def ensure_datetime(obj):
      
      _VALID_TYPES = (str, datetime.datetime, cftime.datetime,
                      np.datetime64)
      if isinstance(obj, _VALID_TYPES):
          return obj
      raise TypeError("datetime-like object required.  "
                      "Type given: {}".format(type(obj)))
docs: Return the object if it is a datetime-like object
  
      Parameters
      ----------
      obj : Object to be tested.
  
      Returns
      -------
      The original object if it is a datetime-like object
  
      Raises
      ------
      TypeError if `obj` is not datetime-like