code: def _convert_time_to_sample(abs_time, dataset):
      
      if isinstance(abs_time, datetime):
          abs_time = abs_time - dataset.header['start_time']
  
      if not isinstance(abs_time, timedelta):
          try:
              abs_time = timedelta(seconds=float(abs_time))
          except TypeError as err:
              if isinstance(abs_time, int64):
                  # timedelta and int64: http://bugs.python.org/issue5476
                  abs_time = timedelta(seconds=int(abs_time))
              else:
                  raise err
  
      sample = int(ceil(abs_time.total_seconds() * dataset.header['s_freq']))
      return sample
docs: Convert absolute time into samples.
  
      Parameters
      ----------
      abs_time : dat
          if it's int or float, it's assumed it's s;
          if it's timedelta, it's assumed from the start of the recording;
          if it's datetime, it's assumed it's absolute time.
      dataset : instance of wonambi.Dataset
          dataset to get sampling frequency and start time
  
      Returns
      -------
      int
          sample (from the starting of the recording).