Jasmine 1.3.x has no sane way of resetting to native clocks, and since we're gonna test promises and such, we're gonna need it
349841
function resetClock() {
  for (const key in jasmine.Clock.real) {
    if (jasmine.Clock.real.hasOwnProperty(key)) {
      window[key] = jasmine.Clock.real[key]
    }
  }
}
1151110
function calculateClockOffset() {
  const start = Date.now();
  let cur = start;
  // Limit the iterations, just in case we're running in an environment where Date.now() has been mocked and is
  // constant.
  for (let i = 0; i < 1e6 && cur === start; i++) {
    cur = Date.now();
  }

  // At this point |cur| "just" became equal to the next millisecond -- the unseen digits after |cur| are approximately
  // all 0, and |cur| is the closest to the actual value of the UNIX time. Now, get the current global monotonic clock
  // value and do the remaining calculations.

  return cur - getGlobalMonotonicClockMS();
}
819586
protected void reschedule(long minTimeoutAt) {
		if (minTimeoutAt == Long.MAX_VALUE) {
			for (PendingPromise pending : promises.values()) {
				if (pending.timeoutAt > 0 && pending.timeoutAt < minTimeoutAt) {
					minTimeoutAt = pending.timeoutAt;
				}
			}
			long timeoutAt;
			requestStreamReadLock.lock();
			try {
				for (IncomingStream stream : requestStreams.values()) {
					timeoutAt = stream.getTimeoutAt();
					if (timeoutAt > 0 && timeoutAt < minTimeoutAt) {
						minTimeoutAt = timeoutAt;
					}
				}
			} finally {
				requestStreamReadLock.unlock();
			}
			responseStreamReadLock.lock();
			try {
				for (IncomingStream stream : responseStreams.values()) {
					timeoutAt = stream.getTimeoutAt();
					if (timeoutAt > 0 && timeoutAt < minTimeoutAt) {
						minTimeoutAt = timeoutAt;
					}
				}
			} finally {
				responseStreamReadLock.unlock();
			}
		}
		long now = System.currentTimeMillis();
		if (minTimeoutAt == Long.MAX_VALUE) {
			ScheduledFuture<?> t = callTimeoutTimer.get();
			if (t != null) {
				if (prevTimeoutAt.get() > now) {
					t.cancel(false);
					prevTimeoutAt.set(0);
				} else {
					callTimeoutTimer.set(null);
					prevTimeoutAt.set(0);
				}
			}
		} else {
			minTimeoutAt = (minTimeoutAt / 100 * 100) + 100;
			long prev = prevTimeoutAt.getAndSet(minTimeoutAt);
			if (prev == minTimeoutAt) {

				// Next when not changed
				return;
			}

			// Stop previous timer
			ScheduledFuture<?> t = callTimeoutTimer.get();
			if (t != null) {
				t.cancel(false);
			}

			// Schedule next timeout timer
			long delay = Math.max(10, minTimeoutAt - now);
			callTimeoutTimer.set(scheduler.schedule(this::checkTimeouts, delay, TimeUnit.MILLISECONDS));
		}
	}
908260
function initPromiseWatcher(watchExpressionForPromise, btnEl) {
          // watch promise to resolve or fail
          scope.$watch(watchExpressionForPromise, function (mVal) {
            minDurationTimeoutDone = false;
            promiseDone = false;

            // create timeout if option is set
            if (cfg.minDuration) {
              minDurationTimeout = $timeout(function () {
                minDurationTimeoutDone = true;
                handleLoadingFinished(btnEl);
              }, cfg.minDuration);
            }

            // for regular promises
            if (mVal && mVal.then) {
              initLoadingState(btnEl);

              // angular promise
              if (mVal.finally) {
                mVal.finally(function () {
                  promiseDone = true;
                  handleLoadingFinished(btnEl);
                });
              }
              // ES6 promises
              else {
                mVal.then(function () {
                    promiseDone = true;
                    handleLoadingFinished(btnEl);
                  })
                  .catch(function () {
                    promiseDone = true;
                    handleLoadingFinished(btnEl);
                  });
              }

            }
            // for $resource
            else if (mVal && mVal.$promise) {
              initLoadingState(btnEl);
              mVal.$promise.finally(function () {
                promiseDone = true;
                handleLoadingFinished(btnEl);
              });
            }
          });
        }
477937
function (test) {
        var end = +(new Date());

        test.runTime = end - test.start;

        results[test.name] = {
            name : test.name,
            runTime : test.runTime,
            baseline : results["__baseline__"] ? (results["__baseline__"].runTime - test.runTime) : NaN
        };

        addSelector(test.selector, test.cfg.incremental);

        // Yeld before calling the callback
        setTimeout(function () {
            next(test);
        }, 15);
    }
367699
function resetPolling(newIntervalInMinutes) {
    if (pollTimerID != null) {
        clearTimeout(pollTimerID);
    }
    pollTimerID = null;
    if (newIntervalInMinutes == null) {
        const settings = pi.setting.getSettings();
        newIntervalInMinutes = settings.Periodical.pollInterval;
    }
    if (typeof newIntervalInMinutes == 'number') {
        const curDate = new Date();
        // Align by nearest hour
        const alignedDate = new Date(
            curDate.getFullYear(), curDate.getMonth(), curDate.getDate(), curDate.getHours());
        const millisDiff = curDate.getTime() - alignedDate.getTime();
        let nextTiming = 0;
        while (nextTiming < millisDiff) {
            nextTiming += newIntervalInMinutes * 60*1000;
        }
        if (nextTiming >= 60*60*1000) {
            nextTiming = 60*60*1000;
        }
        pollTimerID
            = setTimeout(runPollScript
                , nextTiming - millisDiff + 1000 /* margin*/);
    }
}
644881
def reset(self, value=None):
    

    if value is None:
      value = time.clock()
    self.start = value
    if self.value_on_reset:
      self.value = self.value_on_reset
1345563
function() {
        // Important to configure later to not use UTC.
        later.date.localTime();

        // Shutdown on schedule.
        if (this.get('shutdownSchedule')) {
            this._shutdownSchedule = later.parse.cron(this.get('shutdownSchedule'));
            if (this._shutdownInterval) {
                this._shutdownInterval.clear();
            }

            this._shutdownInterval = later.setInterval(_.bind(function() {
                logger.info('App shutdown time has arrived. ' + new Date());
                this.set('restartCount', 0);
                this.shutdownApp();
            }, this), this._shutdownSchedule);
        }

        // Shutdown on schedule.
        if (this.get('shutdownPcSchedule')) {
            this._shutdownPcSchedule = later.parse.cron(this.get('shutdownPcSchedule'));
            if (this._shutdownPcInterval) {
                this._shutdownPcInterval.clear();
            }

            this._shutdownPcInterval = later.setInterval(_.bind(function() {
                logger.info('Machine shutdown time has arrived. ' + new Date());
                this.set('restartCount', 0);
                this.shutdownMachine();
            }, this), this._shutdownPcSchedule);
        }

        // Start up on schedule.
        if (this.get('startupSchedule')) {
            this._startupSchedule = later.parse.cron(this.get('startupSchedule'));
            if (this._startupInterval) {
                this._startupInterval.clear();
            }

            this._startupInterval = later.setInterval(_.bind(function() {
                logger.info('App startup time has arrived. ' + new Date());
                if (!$$serverState.get('runApp')) {
                    logger.info('Startup disabled by console.');
                    return;
                }

                this.set('restartCount', 0);
                this.startApp();
            }, this), this._startupSchedule);
        }

        // Start up on schedule.
        if (this.get('restartSchedule')) {
            this._restartSchedule = later.parse.cron(this.get('restartSchedule'));
            if (this._restartInterval) {
                this._restartInterval.clear();
            }

            this._restartInterval = later.setInterval(_.bind(function() {
                if (this._isStartingUp || this._isShuttingDown) {
                    return;
                }

                logger.info('App restart time has arrived. ' + new Date());
                if (!$$serverState.get('runApp')) {
                    logger.info('Startup disabled by console.');
                    return;
                }

                this.set('restartCount', 0);
                this.restartApp();
            }, this), this._restartSchedule);
        }

        // Restart machine on schedule.
        if (this.get('restartPcSchedule')) {
            this._restartPcSchedule = later.parse.cron(this.get('restartPcSchedule'));
            if (this._restartPcInterval) {
                this._restartPcInterval.clear();
            }

            this._restartPcInterval = later.setInterval(_.bind(function() {
                logger.info('Machine restart time has arrived. ' + new Date());

                this.restartMachine();

            }, this), this._restartPcSchedule);
        }

    }
1067038
function (h, m) {
/*Line 89 - 'AtomTimePicker.js' */                var ap = 'AM';
/*Line 90 - 'AtomTimePicker.js' */                if (h > 12) {
/*Line 91 - 'AtomTimePicker.js' */                    h -= 12;
/*Line 92 - 'AtomTimePicker.js' */                    ap = "PM";
/*Line 93 - 'AtomTimePicker.js' */                }
/*Line 94 - 'AtomTimePicker.js' */                h = "" + h;
/*Line 95 - 'AtomTimePicker.js' */                if (h.length == 1) {
/*Line 96 - 'AtomTimePicker.js' */                    h = "0" + h;
/*Line 97 - 'AtomTimePicker.js' */                }
/*Line 98 - 'AtomTimePicker.js' */                m = m + "";
/*Line 99 - 'AtomTimePicker.js' */                if (m.length == 1) {
/*Line 100 - 'AtomTimePicker.js' */                    m = "0" + m;
/*Line 101 - 'AtomTimePicker.js' */                }
/*Line 102 - 'AtomTimePicker.js' */                AtomBinder.setValue(this, "value", h + ":" + m + " " + ap);
/*Line 103 - 'AtomTimePicker.js' */            }
1374404
function (cb) {
					Nightwatch.runner(argv, function (status) {
						var err = null;
						if (status) {
							console.log([moment().format('HH:mm:ss:SSS')] + ' kne: tests passed');
						} else {
							console.log([moment().format('HH:mm:ss:SSS')] + ' kne: tests failed');
							err = new Error('kne: nightwatch runner returned an error status code');
						}
						cb(err);
					});
				}
1201684
function (fn, repeatTest = 0, args = []) {
    /**
     * if a new hook gets executed we can assume that all commands should have finised
     * with exception of timeouts where `commandIsRunning` will never be reset but here
     */
    // commandIsRunning = false

    return new Promise((resolve, reject) => {
        try {
            const res = fn.apply(this, args)
            resolve(res)
        } catch (e) {
            if (repeatTest) {
                return resolve(executeSync(fn, --repeatTest, args))
            }

            /**
             * no need to modify stack if no stack available
             */
            if (!e.stack) {
                return reject(e)
            }

            e.stack = e.stack.split('\n').filter(STACKTRACE_FILTER_FN).join('\n')
            reject(e)
        }
    })
}
1326843
def reset_time(path='.', amt=None):
    '''
    
    '''
    if not amt:
        amt = int(time.time())
    for fname in os.listdir(path):
        fname = os.path.join(path, fname)
        if os.path.isdir(fname):
            reset_time(fname, amt=amt)
        os.utime(fname, (amt, amt,))
964979
function TimeoutModule(Component){

  Component.implement({
    /**
     * just like setTimeout, but will enter digest automately
     * @param  {Function} fn    
     * @param  {Number}   delay 
     * @return {Number}   timeoutid
     */
    $timeout: function(fn, delay){
      delay = delay || 0;
      return setTimeout(function(){
        fn.call(this);
        this.$update(); //enter digest
      }.bind(this), delay);
    },
    /**
     * just like setInterval, but will enter digest automately
     * @param  {Function} fn    
     * @param  {Number}   interval 
     * @return {Number}   intervalid
     */
    $interval: function(fn, interval){
      interval = interval || 1000/60;
      return setInterval(function(){
        fn.call(this);
        this.$update(); //enter digest
      }.bind(this), interval);
    }
  });
}
792409
function debounceTime(dueTime, scheduler) {
    if (scheduler === void 0) {
        scheduler = _scheduler_async__WEBPACK_IMPORTED_MODULE_2__["async"];
    }
    return function (source) { return source.lift(new DebounceTimeOperator(dueTime, scheduler)); };
}
809642
function flushOnChangesQueue() {
      try {
        if (!(--onChangesTtl)) {
          // We have hit the TTL limit so reset everything
          onChangesQueue = undefined;
          throw $compileMinErr('infchng', '{0} $onChanges() iterations reached. Aborting!\n', TTL);
        }
        // We must run this hook in an apply since the $$postDigest runs outside apply
        $rootScope.$apply(function() {
          for (var i = 0, ii = onChangesQueue.length; i < ii; ++i) {
            onChangesQueue[i]();
          }
          // Reset the queue to trigger a new schedule next time there is a change
          onChangesQueue = undefined;
        });
      } finally {
        onChangesTtl++;
      }
    }
951230
function AnyTimer(fn, timeval, isInterval) {
	this.clear = clear
	var isClear
	if (!(timeval >= 1)) timeval = 1 // ensure number
	var baseTime = Date.now()
	var nextTargetTime = baseTime + timeval
	var timer
	var interval

	if (isInterval && timeval <= TIMEOUT_MAX) { // this actually works with setInterval
		interval = setInterval(fn, timeval)
	} else timerFire()

	function timerFire() {
		var remaining = nextTargetTime - Date.now()
		if (remaining <= 0) {
			timer = null
			fn()
			if (isInterval && !isClear) {
				nextTargetTime += isInterval
				setTimer(nextTargetTime - Date.now())
			}
		} else setTimer(remaining)
	}

	function setTimer(remaining) {
		if (remaining >= time1day) remaining = time1day
		timer = setTimeout(timerFire, remaining)
	}

	function clear() {
		isClear = true
		if (timer) {
			var t = timer
			timer = null
			clearTimeout(t)
		}
		if (interval) {
			var i = interval
			interval = null
			clearInterval(i)
		}
	}
}
114844
function toHaveBeenDone() {
  var getErrorMsg = jasmine.formatErrorMsg('<toHaveBeenDone>', 'expect(<scopeObj>).toHaveBeenDone()');
  var pp = jasmine.pp;

  return {
    compare: function (actual) {
      var result = { pass: false };

      if (!actual.isDone) {
        throw new Error(getErrorMsg('Expected a nock scope, but got ' + pp(actual) + '.'));
      }

      if (actual.basePath) {
        var key = actual.interceptors[0]._key;
        if (actual.isDone()) {
          result.pass = true;
          result.message = 'Expected nock scope expectation "' + key + '" not to have been done but it was.';
        } else {
          result.message = 'Expected nock scope expectation "' + key + '" to have been done but it was never done.';
        }

        return result;
      }

      if (actual.isDone()) {
        result.pass = true;
        result.message = 'Expected nock expectations to have not been done but they were done.';
      } else {
        result.message = 'Expected nock expectations to have been done but they were never done.';
      }

      return result;
    }
  };
}