def get_loc(self, key):
        """Adapted from pandas.tseries.index.DatetimeIndex.get_loc"""
        if isinstance(key, str):
            return self._get_string_slice(key)
        else:
            return super().get_loc(key)
Adapted from pandas.tseries.index.DatetimeIndex.get_loc
xarray/coding/cftimeindex.py