def time_as_index(self, times, use_rounding=False):
        from ..source_estimate import _BaseSourceEstimate
        if isinstance(self, _BaseSourceEstimate):
            sfreq = 1. / self.tstep
        else:
            sfreq = self.info['sfreq']
        index = (np.atleast_1d(times) - self.times[0]) * sfreq
        if use_rounding:
            index = np.round(index)
        return index.astype(int)
Convert time to indices
dataset/ETHPy150Open mne-tools/mne-python/mne/io/base.py/TimeMixin.time_as_index