code: def _find_start_time(hdr, s_freq):
      
      start_time = hdr['stc']['creation_time']
  
      for one_stamp in hdr['stamps']:
          if one_stamp['segment_name'].decode() == hdr['erd']['filename']:
              offset = one_stamp['start_stamp']
              break
  
      erd_time = (hdr['erd']['creation_time'] -
                  timedelta(seconds=offset / s_freq)).replace(microsecond=0)
  
      stc_erd_diff = (start_time - erd_time).total_seconds()
      if stc_erd_diff > START_TIME_TOL:
          lg.warn('Time difference between ERD and STC is {} s so using ERD time'
                  ' at {}'.format(stc_erd_diff, erd_time))
          start_time = erd_time
  
      return start_time
docs: Find the start time, usually in STC, but if that's not correct, use ERD
  
      Parameters
      ----------
      hdr : dict
          header with stc (and stamps) and erd
      s_freq : int
          sampling frequency
  
      Returns
      -------
      datetime
          either from stc or from erd
  
      Notes
      -----
      Sometimes, but rather rarely, there is a mismatch between the time in the
      stc and the time in the erd. For some reason, the time in the stc is way
      off (by hours), which is clearly not correct.
  
      We can try to reconstruct the actual time, but looking at the ERD time
      (of any file apart from the first one) and compute the original time back
      based on the offset of the number of samples in stc. For some reason, this
      is not the same for all the ERD, but the jitter is in the order of 1-2s
      which is acceptable for our purposes (probably, but be careful about the
      notes).