parameters: (func: F)
return_statement: return cast(F, new_func)
docstring: Wrapper to handle datetime64 and timedelta64 dtypes.
docstring_summary: Wrapper to handle datetime64 and timedelta64 dtypes.
docstring_tokens: Wrapper to handle datetime64 and timedelta64 dtypes .
function: def _datetimelike_compat(func: F) -> F:
      """
      Wrapper to handle datetime64 and timedelta64 dtypes.
      """
  
      @wraps(func)
      def new_func(values, limit=None, mask=None):
          if needs_i8_conversion(values.dtype):
              if mask is None:
                  # This needs to occur before casting to int64
                  mask = isna(values)
  
              result, mask = func(values.view("i8"), limit=limit, mask=mask)
              return result.view(values.dtype), mask
  
          return func(values, limit=limit, mask=mask)
  
      return cast(F, new_func)
function_tokens: def _datetimelike_compat ( func : F ) -> F : @ wraps ( func ) def new_func ( values , limit = None , mask = None ) : if needs_i8_conversion ( values . dtype ) : if mask is None : # This needs to occur before casting to int64 mask = isna ( values ) result , mask = func ( values . view ( "i8" ) , limit = limit , mask = mask ) return result . view ( values . dtype ) , mask return func ( values , limit = limit , mask = mask ) return cast ( F , new_func )