def is_datetime_like(
    dtype: np.dtype[np.generic],
) -> TypeGuard[np.datetime64 | np.timedelta64]:
    """Check if a dtype is a subclass of the numpy datetime types"""
    return np.issubdtype(dtype, np.datetime64) or np.issubdtype(dtype, np.timedelta64)
Check if a dtype is a subclass of the numpy datetime types
xarray/namedarray/dtypes.py