return time offset (seconds) of next PCM sample to be read
545896
public float time_tell(){
    // translate time to PCM position and call pcm_seek

    int link=-1;
    long pcm_total=0;
    float time_total=0.f;

    if(seekable){
      pcm_total=pcm_total(-1);
      time_total=time_total(-1);

      // which bitstream section does this time offset occur in?
      for(link=links-1; link>=0; link--){
        pcm_total-=pcmlengths[link];
        time_total-=time_total(link);
        if(pcm_offset>=pcm_total)
          break;
      }
    }

    return ((float)time_total+(float)(pcm_offset-pcm_total)/vi[link].rate);
  }
755405
def update(self, pbar):
        """"""
        if pbar.currval == 0:
            return 'ETA:  --:--:--'
        elif pbar.finished:
            return 'Time: %s' % self.format_time(pbar.seconds_elapsed)
        else:
            elapsed = pbar.seconds_elapsed
            currval1, elapsed1 = self._update_samples(pbar.currval, elapsed)
            eta = self._eta(pbar.maxval, pbar.currval, elapsed)
            if pbar.currval > currval1:
                etasamp = self._eta(pbar.maxval - currval1,
                                    pbar.currval - currval1,
                                    elapsed - elapsed1)
                weight = (pbar.currval / float(pbar.maxval)) ** 0.5
                eta = (1 - weight) * eta + weight * etasamp
            return 'ETA:  %s' % self.format_time(eta)
575687
def i2repr(self, pkt, packed_seconds):
        """"""
        time_struct = time.gmtime(self._convert_seconds(packed_seconds))
        return time.strftime("%a %b %d %H:%M:%S %Y", time_struct)
38193
def from_datetime(self, dt):
        
        global _last_timestamp

        epoch = datetime(1970, 1, 1, tzinfo=dt.tzinfo)
        offset = epoch.tzinfo.utcoffset(epoch).total_seconds() if epoch.tzinfo else 0
        timestamp = (dt  - epoch).total_seconds() - offset

        node = None
        clock_seq = None

        nanoseconds = int(timestamp * 1e9)
        timestamp = int(nanoseconds // 100) + 0x01b21dd213814000

        if clock_seq is None:
            import random
            clock_seq = random.randrange(1 << 14)  # instead of stable storage
        time_low = timestamp & 0xffffffff
        time_mid = (timestamp >> 32) & 0xffff
        time_hi_version = (timestamp >> 48) & 0x0fff
        clock_seq_low = clock_seq & 0xff
        clock_seq_hi_variant = (clock_seq >> 8) & 0x3f
        if node is None:
            node = getnode()
        return pyUUID(fields=(time_low, time_mid, time_hi_version,
                            clock_seq_hi_variant, clock_seq_low, node), version=1)
1287352
def utcfromtimestamp(cls, t):
        ""
        t, frac = divmod(t, 1.0)
        us = int(frac * 1e6)

        # If timestamp is less than one microsecond smaller than a
        # full second, us can be rounded up to 1000000.  In this case,
        # roll over to seconds, otherwise, ValueError is raised
        # by the constructor.
        if us == 1000000:
            t += 1
            us = 0
        y, m, d, hh, mm, ss, weekday, jday, dst = _time.gmtime(t)
        ss = min(ss, 59)    # clamp out leap seconds if the platform has them
        return cls(y, m, d, hh, mm, ss, us)
147115
function() {
      let sample = clock(start)

      if (test.after) test.after()
      bench.after.forEach(call)

      if (warmups == -1) {
        warmups = Math.max(minWarmups, sample > 100 ? 1 : sample > 10 ? 5 : 50)
      }
      if (warmups > 0) {
        warmups--
      } else {
        samples[n++] = sample
        onSample(samples[n - 1], cycle)

        if (minTime <= clock(t) && minSamples <= n) {
          return cycle.done() // all done!
        }
      }

      // wait then repeat
      wait(delay).then(next)
    }
328143
private synchronized void checkNextSecond(double nowInMsRoundedAtSec) {
        // next second
        if (time == nowInMsRoundedAtSec) {
            return;
        }

        if (startSec == 0) {
            startSec = nowInMsRoundedAtSec;
        }
        time = nowInMsRoundedAtSec;

        Pair<Double, Long> pair = getRPSForSecond((nowInMsRoundedAtSec - startSec) / 1000);
        double nextRps = pair.getLeft();
        if (nextRps < 0) {
            stopping = true;
            int factor = stopTries > 10 ? 2 : 1;
            rps = rps > 0 ? rps * factor : 1;
            stopTest();
            notifyAll();
        } else {
            rps = nextRps;
        }

        if (log.isDebugEnabled()) {
            log.debug("Second changed {} , waiting: {}, samples sent {}, current rps: {} rps",
                    ((nowInMsRoundedAtSec - startSec) / 1000), cntDelayed, cntSent, rps);
        }

        if (cntDelayed < 1 && cntSent < rps) {
            log.warn("No free threads available in current Thread Group {}, made {} samples/s for expected rps {} samples/s, increase your number of threads",
                    JMeterContextService.getContext().getThreadGroup().getName(), cntSent, rps);
        }

        String elementName = getName();
        JMeterUtils.setProperty(elementName + "_totalDuration", String.valueOf(pair.getRight()));
        JMeterUtils.setProperty(elementName + "_cntDelayed", String.valueOf(cntDelayed));
        JMeterUtils.setProperty(elementName + "_cntSent", String.valueOf(cntSent));
        JMeterUtils.setProperty(elementName + "_rps", String.valueOf(rps));

        cntSent = 0;
        msecPerReq = 1000d / rps;
    }
195058
def num_samples(self):
        
        with audioread.audio_open(self.path) as f:
            return int(f.duration * f.samplerate)
1283076
def fix_repeat_dt(dt_list, offset_s=0.001):
    
    idx = (np.diff(dt_list) == timedelta(0))
    while np.any(idx):
        dt_list[idx.nonzero()[0] + 1] += timedelta(seconds=offset_s)
        idx = (np.diff(dt_list) == timedelta(0))
    return dt_list
898798
def _pulse_data(self, value):
        """"""
        if self._i2c_expander == 'PCF8574':
            self.bus.write_byte(self._address, ((value & ~PCF8574_E) | self._backlight))
            c.usleep(1)
            self.bus.write_byte(self._address, value | PCF8574_E | self._backlight)
            c.usleep(1)
            self.bus.write_byte(self._address, ((value & ~PCF8574_E) | self._backlight))
            c.usleep(100)
        elif self._i2c_expander in ['MCP23008', 'MCP23017']:
            self._mcp_data &= ~MCP230XX_DATAMASK
            self._mcp_data |= value << MCP230XX_DATASHIFT
            self._mcp_data &= ~MCP230XX_E
            self.bus.write_byte_data(self._address, self._mcp_gpio, self._mcp_data)
            c.usleep(1)
            self._mcp_data |= MCP230XX_E
            self.bus.write_byte_data(self._address, self._mcp_gpio, self._mcp_data)
            c.usleep(1)
            self._mcp_data &= ~MCP230XX_E
            self.bus.write_byte_data(self._address, self._mcp_gpio, self._mcp_data)
            c.usleep(100)
164174
def total_seconds(offset):
    """"""
    seconds = offset.days * 24 * 60 * 60 + offset.seconds
    microseconds = seconds * 10**6 + offset.microseconds
    return microseconds / (10**6 * 1.0)
1243074
def frame_generator(frame_duration_ms, audio, sample_rate):
    
    n = int(sample_rate * (frame_duration_ms / 1000.0) * 2)
    offset = 0
    timestamp = 0.0
    duration = (float(n) / sample_rate) / 2.0
    while offset + n < len(audio):
        yield Frame(audio[offset:offset + n], timestamp, duration)
        timestamp += duration
        offset += n
170148
function getHrTimeDurationInMs (startTime, endTime) {
    if (startTime === null || endTime === null) {
        return null;
    }

    var secondDiff = endTime[0] - startTime[0];
    var nanoSecondDiff = endTime[1] - startTime[1];
    var diffInNanoSecond = secondDiff * NS_PER_SEC + nanoSecondDiff;

    return Math.round(diffInNanoSecond / MS_PER_NS);
}
486077
private long readTimeStamp(byte[] buffer, int offset) {
        long seconds = read32(buffer, offset);
        long fraction = read32(buffer, offset + 4);
        return ((seconds - OFFSET_1900_TO_1970) * 1000) + ((fraction * 1000L) / 0x100000000L);
    }
519086
def get_time(self, idx):
        """"""
        # raw data
        qpi = self.get_qpimage_raw(idx)
        if "time" in qpi.meta:
            thetime = qpi.meta["time"]
        else:
            thetime = np.nan
        return thetime
479137
def clip_to_seconds(m: Union[int, pd.Series]) -> Union[int, pd.Series]:
        """"""
        return m // pd.Timedelta(1, unit='s').value
244379
def pttl(self, key):
        
        """
        Returns time to live in milliseconds if output_ms is True, else returns seconds.
        """
        key = self._encode(key)
        if key not in self.redis:
            # as of redis 2.8, -2 is returned if the key does not exist
            return long(-2) if self.strict else None
        if key not in self.timeouts:
            # as of redis 2.8, -1 is returned if the key is persistent
            # redis-py returns None; command docs say -1
            return long(-1) if self.strict else None

        time_to_live = get_total_milliseconds(self.timeouts[key] - self.clock.now())
        return long(max(-1, time_to_live))