**********************************
Relative Time
********************************** helper function for moment.fn.from, moment.fn.fromNow, and moment.duration.fn.humanize
435286
function substituteTimeAgo(string, number, withoutSuffix, isFuture, lang) {
        var rt = lang.relativeTime[string];
        return (typeof rt === 'function') ?
            rt(number || 1, !!withoutSuffix, string, isFuture) :
            rt.replace(/%d/i, number || 1);
    }
527795
function wrapTimerHandler(vHandler) {
				var fnWrappedHandler = function() {
					var aArgs, fnHandler;
					if (bPromisesQueued) {
						aArgs = [fnWrappedHandler, 0].concat(arguments);
						_timeout.apply(window, aArgs);
					} else {
						fnHandler = typeof vHandler !== "function" ? new Function(vHandler) : vHandler; // eslint-disable-line no-new-func
						fnHandler.apply(window, arguments);
					}
				};
				return fnWrappedHandler;
			}
682981
def query_relative(self, query, event_time=None, relative_duration_before=None, relative_duration_after=None):
        """"""
        assert event_time is None or isinstance(event_time, datetime.datetime)
        assert relative_duration_before is None or isinstance(relative_duration_before, str)
        assert relative_duration_after is None or isinstance(relative_duration_after, str)

        if event_time is None:
            # use now as the default 
            event_time = datetime.datetime.now()

        # use preconfigured defaults
        if relative_duration_before is None:
            relative_duration_before = self.relative_duration_before

        if relative_duration_after is None:
            relative_duration_after = self.relative_duration_after
        
        time_start = event_time - create_timedelta(relative_duration_before)
        time_end = event_time + create_timedelta(relative_duration_after)
        return self.query_with_time(query, time_start, time_end)
1117951
function getColonTime(timeString) {
  var totalSeconds = 0;
  var timeValues = [
    1,
    1 * 60,
    1 * 60 * 60,
    1 * 60 * 60 * 24,
    1 * 60 * 60 * 24 * 7,
  ];
  var timePairs = timeString.split(':');
  for (var i = 0; i < timePairs.length; i++) {
    totalSeconds += parseInt(timePairs[i], 10) * timeValues[timePairs.length - i - 1];
  }
  return totalSeconds;
}
1273087
function(anim, att, from, to, elapsed, duration, fn, unit) {
        from = Number(from);
        to = Number(to);

        var node = anim._node,
            val = Transition.cubicBezier(fn, elapsed / duration);

        val = from + val[0] * (to - from);

        if (att in node._node.style || att in Y.DOM.CUSTOM_STYLES) {
            unit = unit || '';
            node.setStyle(att, val + unit);
        } else if (node._node.attributes[att]) {
            node.setAttribute(att, val);
        } else {
            node.set(att, val);
        }
    }
582818
function( time ) {
		var h, m, s;

		if ( time > TIME_MINUTE ) {
			m = parseInt( time / TIME_MINUTE, 10 );
			s = ( time % TIME_MINUTE ) / TIME_SECOND;
			return m + 'mins, ' + s + 's';
		}
		else if ( time > TIME_SECOND ) {
			return ( time / TIME_SECOND ) + 's';
		}
		else {
			return time + 'ms';
		}
	}
1193029
function (time) {
            last = now;
            now = time;
            delta = (now - last);

            // fix for negative timestamp returned by wechat or chrome on startup
            if (delta < 0) {
                delta = 0;
            }

            // get the game tick
            api.tick = (delta > minstep && me.sys.interpolation) ? delta / step : 1;

            for (var i = 0, len = timers.length; i < len; i++) {
                var _timer = timers[i];
                if (!(_timer.pauseable && me.state.isPaused())) {
                    _timer.elapsed += delta;
                }
                if (_timer.elapsed >= _timer.delay) {
                    _timer.fn.apply(null, _timer.args);
                    if (_timer.repeat === true) {
                        _timer.elapsed -= _timer.delay;
                    } else {
                        me.timer.clearTimeout(_timer.timerId);
                    }
                }
            }
        }
726862
function createDateTimeFormatter( type, inputFormat ) {
   return ( options, value ) => {
      if( value == null ) {
         return '';
      }

      if( value instanceof Date ) {
         return format( moment( value ) );
      }

      if( typeof value !== 'string' ) {
         throw argumentError( value );
      }

      const useInputFormat = value.length < ISO_FULL_FORMAT_MIN_LENGTH;
      const momentTime = value.toLowerCase() === 'now' ?
         moment() :
         moment( value, useInputFormat ? inputFormat : undefined, useInputFormat || undefined );

      if( !momentTime.isValid() ) {
         throw argumentError( value );
      }

      return format( momentTime );

      ////////////////////////////////////////////////////////////////////////////////////////////////////////

      function format( momentTime ) {
         return momentTime.format( options[ `${type}Format` ] );
      }

      function argumentError( value ) {
         return new TypeError(
            'Expected argument to be a Date object, the string "NOW", or an ISO-8601 string ' +
            `(full, or ${type} as ${inputFormat}), but got "${typeof value}". Value: ${value}`
         );
      }
   };
}
1152426
def timed_do_fn(f):
    """"""
    def wrap(callable, *args, **kwargs):
        global _debug_id

        # get a description of the function that called us
        st = traceback.extract_stack(limit=2)
        file, line, name, _ = st[0]

        # and its locals
        frame = inspect.currentframe()
        locals = frame.f_locals

        # invent a unique ID for the description
        id, _debug_id = _debug_id, _debug_id + 1

        descr = "%s-%08x" % (name, id)

        start_time = time.time()
        log.msg("%s - before ('%s' line %d)" % (descr, file, line))
        for name in locals:
            if name in ('self', 'thd'):
                continue
            log.msg("%s -   %s = %r" % (descr, name, locals[name]))

        # wrap the callable to log the begin and end of the actual thread
        # function
        def callable_wrap(*args, **kargs):
            log.msg("%s - thd start" % (descr,))
            try:
                return callable(*args, **kwargs)
            finally:
                log.msg("%s - thd end" % (descr,))
        d = f(callable_wrap, *args, **kwargs)

        @d.addBoth
        def after(x):
            end_time = time.time()
            elapsed = (end_time - start_time) * 1000
            log.msg("%s - after (%0.2f ms elapsed)" % (descr, elapsed))
            return x
        return d
    wrap.__name__ = f.__name__
    wrap.__doc__ = f.__doc__
    return wrap
1023810
function getFuzzyLocalTimeFromPoint(timestamp, point) {
  var tile = tilebelt.pointToTile(point[0], point[1], z).join('/');
  var locale = tiles[tile];

  if (locale) return moment.tz(new Date(timestamp), locale);
  else return undefined;
}
933763
function hrtimer() {
    const start = process.hrtime();

    return () => {
      const durationComponents = process.hrtime(start);
      const seconds = durationComponents[0];
      const nanoseconds = durationComponents[1];
      const duration = (seconds * 1000) + (nanoseconds / 1E6);
      return duration;
    };
  }
339020
def humanize_time(secs)
      [[60, :s], [60, :m], [24, :h], [1000, :d]].map { |count, name|
        if secs.positive?
          secs, n = secs.divmod(count)
          "#{n.to_i}#{name}"
        end
      }.compact.reverse.join(' ')
    end
985391
def humanize_time_since(timestamp=None):
    
    timeDiff = datetime.datetime.now() - timestamp
    days = timeDiff.days
    hours = timeDiff.seconds / 3600
    minutes = timeDiff.seconds % 3600 / 60
    seconds = timeDiff.seconds % 3600 % 60

    str = ""
    if days > 0:
        if days == 1:
            t_str = "day"
        else:
            t_str = "days"
        str += "{0} {1}".format(days, t_str)
        return str
    elif hours > 0:
        if hours == 1:
            t_str = "hour"
        else:
            t_str = "hours"
        str += "{0} {1}".format(hours, t_str)
        return str
    elif minutes > 0:
        if minutes == 1:
            t_str = "min"
        else:
            t_str = "mins"
        str += "{0} {1}".format(minutes, t_str)
        return str
    elif seconds > 0:
        if seconds == 1:
            t_str = "sec"
        else:
            t_str = "secs"
        str += "{0} {1}".format(seconds, t_str)
        return str
    else:
        return str
1291867
private static Moment moveEventuallyToLS(Moment adjusted) {

        PlainDate date = adjusted.getDateUTC();
        PlainTime time = adjusted.getTimeUTC();

        if (
            (LeapSeconds.getInstance().getShift(date) == 1)
            && (time.getHour() == 23)
            && (time.getMinute() == 59)
            && (time.getSecond() == 59)
        ) {
            return adjusted.plus(1, SI.SECONDS);
        } else {
            return adjusted;
        }

    }
373149
function Moment(date, isUTC, lang) {
        this._d = date;
        this._isUTC = !!isUTC;
        this._a = date._a || null;
        this._lang = lang || false;
    }
454154
function humanize (ms)
{
	if (ms >= HOUR)
		return (ms / HOUR).toFixed(1) + 'h';
	
	if (ms >= MIN)
		return (ms / MIN).toFixed(1) + 'm';
	
	if (ms >= SEC) 
		return (ms / SEC | 0) + 's';
	
	return ms + 'ms';
}
258334
function makeRecencyFilter(timeFn) {
  var lastTime = 0;

  return function(items) {
    var out = [];
    items.forEach(function(item) {
      if (timeFn(item) > lastTime) {
        out.push(item);
      }
    });
    out.forEach(function(item) {
      lastTime = Math.max(lastTime, timeFn(item));
    });

    return out;
  };
}