Format time for easy matcher reporting

 @param [Float] time
   the time to format

 @return [String]
   the human readable time value

 @api public
974494
def format_time(time)
      if time >= 100.0
        "%.0f sec" % [time]
      elsif time >= 1.0
        "%.3g sec" % [time]
      elsif time >= 1e-3
        "%.3g ms" % [time * 1e3]
      elsif time >= 1e-6
        "%.3g μs" % [time * 1e6]
      else
        "%.0f ns" % [time * 1e9]
      end
    end
1085908
def parse_time
      s0 = @current_pos
      if match_str("T") != :failed
        s2 = match_digits
        if parse_nl != :failed
          @reported_pos = s0
          s0 = { "now" => sec2time(s2.join.to_i) }
        else
          @current_pos = s0
          s0 = :failed
        end
      else
        @current_pos = s0
        s0 = :failed
      end
      s0
    end
30577
def _strftime(pattern, time_struct=time.localtime()):
    
    try:
        return time.strftime(pattern, time_struct)
    except OSError:
        dt = datetime.datetime.fromtimestamp(_mktime(time_struct))
        # This is incredibly hacky and will probably break with leap
        # year overlaps and shit. Any complaints should go here:
        # https://support.microsoft.com/
        original = dt.year
        current = datetime.datetime.now().year
        dt = dt.replace(year=current)
        ts = dt.timestamp()
        if _isdst(dt):
            ts -= 3600
        string = time.strftime(pattern, time.localtime(ts))
        string = string.replace(str(current), str(original))
        return string
161251
def valid_time(x: str) -> bool:
    
    if isinstance(x, str) and (
        re.match(TIME_PATTERN1, x) or re.match(TIME_PATTERN2, x)
    ):
        return True
    else:
        return False
843974
def format_value(value, options)
      return value.to_s.upcase if options[:type] == Symbol

      value = value.utc if options[:type] == Time

      return value.strftime(Array(options.fetch(:format)).first) if [Date, Time].include? options[:type]

      value
    end
1002369
def format_dates! format=nil
      each do |row|
        row.each_with_index do |value, idx|
          unless row.formats[idx] || row.format(idx).date_or_time?
            numfmt = case value
                     when DateTime, Time
                       format || client('DD.MM.YYYY hh:mm:ss', 'UTF-8')
                     when Date
                       format || client('DD.MM.YYYY', 'UTF-8')
                     end
            case numfmt
            when Format
              row.set_format idx, numfmt
            when String
              fmt = row.format(idx).dup
              fmt.number_format = numfmt
              row.set_format idx, fmt
            end
          end
        end
      end
    end
631677
def format_time(time):
    
    h, r = divmod(time / 1000, 3600)
    m, s = divmod(r, 60)

    return "%02d:%02d:%02d" % (h, m, s)
309668
def parse(
        self,
        time,  # type: str
        fmt,  # type: str
        now,  # type: pendulum.DateTime
        locale=None,  # type:  typing.Union[str, None]
    ):  # type: (...) -> dict
        
        escaped_fmt = re.escape(fmt)

        tokens = self._FROM_FORMAT_RE.findall(escaped_fmt)
        if not tokens:
            return time

        if not locale:
            locale = pendulum.get_locale()

        locale = Locale.load(locale)

        parsed = {
            "year": None,
            "month": None,
            "day": None,
            "hour": None,
            "minute": None,
            "second": None,
            "microsecond": None,
            "tz": None,
            "quarter": None,
            "day_of_week": None,
            "day_of_year": None,
            "meridiem": None,
            "timestamp": None,
        }

        pattern = self._FROM_FORMAT_RE.sub(
            lambda m: self._replace_tokens(m.group(0), locale), escaped_fmt
        )

        if not re.match(pattern, time):
            raise ValueError("String does not match format {}".format(fmt))

        re.sub(pattern, lambda m: self._get_parsed_values(m, parsed, locale, now), time)

        return self._check_parsed(parsed, now)
460832
def humantime(time):
    
    try:
        time = float(time)
    except (ValueError, TypeError):
        raise ValueError("Input must be numeric")

    # weeks
    if time >= 7 * 60 * 60 * 24:
        weeks = math.floor(time / (7 * 60 * 60 * 24))
        timestr = "{:g} weeks, ".format(weeks) + humantime(time % (7 * 60 * 60 * 24))

    # days
    elif time >= 60 * 60 * 24:
        days = math.floor(time / (60 * 60 * 24))
        timestr = "{:g} days, ".format(days) + humantime(time % (60 * 60 * 24))

    # hours
    elif time >= 60 * 60:
        hours = math.floor(time / (60 * 60))
        timestr = "{:g} hours, ".format(hours) + humantime(time % (60 * 60))

    # minutes
    elif time >= 60:
        minutes = math.floor(time / 60.)
        timestr = "{:g} min., ".format(minutes) + humantime(time % 60)

    # seconds
    elif (time >= 1) | (time == 0):
        timestr = "{:g} s".format(time)

    # milliseconds
    elif time >= 1e-3:
        timestr = "{:g} ms".format(time * 1e3)

    # microseconds
    elif time >= 1e-6:
        timestr = "{:g} \u03BCs".format(time * 1e6)

    # nanoseconds or smaller
    else:
        timestr = "{:g} ns".format(time * 1e9)

    return timestr
708994
def _format_time(seconds):
    

    # Always do minutes and seconds in mm:ss format
    minutes = seconds // 60
    hours = minutes // 60
    rtn = u'{0:02.0f}:{1:02.0f}'.format(minutes % 60, seconds % 60)

    #  Add hours if there are any
    if hours:

        rtn = u'{0:d}h {1}'.format(int(hours % 24), rtn)

        #  Add days if there are any
        days = int(hours // 24)
        if days:
            rtn = u'{0:d}d {1}'.format(days, rtn)

    return rtn
71427
def format_datetime(value)
      case value
      when DateTime, Time
        value.strftime('%FT%T.%9N%:z')
      when String
        value
      else
        raise ArgumentError, "unsupported type '#{value.class}' of time value '#{value}'"
      end
    end
979762
def format(options)
      options.map do |key, value|
        [{
          format: :f,
          size: :s,
          length: :hls_time,
        }[key] || key, value].map(&:to_s).join('=')
      end
    end
1044644
def minute(date)
      time = [pad(date.hour.to_s), pad(date.minute.to_s)].join(':')
      [time, day(date)].join(' ')
    end
999326
function formatTime(time) {
				if (time == '') {
					if (settings.required) return settings.duration ? '0:00' : '00:00';
					else return time;
				}
				if ((new RegExp('^(-|\\+)?([0-9]+)(.([0-9]{1,2})?)?$', 'i')).test(time)) {
					var hour = parseInt(RegExp.$2);
					var min = parseInt(RegExp.$4);
					if (!min) min = 0;
					var negative = settings.duration && settings.durationNegative && RegExp.$1 == '-' ? true : false;
					if (hour >= 24 && !settings.duration) hour = hour % 24;
					if (min >= 60) min = min % 60;
					if (settings.precision != 1) {
						var f = Math.floor(min / settings.precision);
						min = f * settings.precision + (Math.round((min - f * settings.precision) / settings.precision) == 1 ? settings.precision : 0);
						if (min >= 60) min = 0;
					}
					time = (negative ? '-' : '') + (hour < 10 && !settings.duration ? '0' : '') + hour + settings.separator + (RegExp.$3 ? (min < 10 ? '0' : '') + min : '00');
				}
				else if ((new RegExp('^(-|\\+)?.([0-9]{1,2})')).test(time)) {
					var min = parseInt(RegExp.$2);
					var negative = settings.duration && settings.durationNegative && RegExp.$1 == '-' ? true : false;
					if (min >= 60) min = min % 60;
					time = (negative && min > 0 ? '-' : '') + '0' + (!settings.duration ? '0' : '') + settings.separator + (min < 10 ? '0' : '') + min;
				}
				else {
					time = '0' + (!settings.duration ? '0' : '') + settings.separator + '00';
				}
				return (settings.duration && settings.useDurationPlusSign && !time.match(/^\-/) && !time.match(/^0+:00$/) ? '+' : '') + time;
			}
410349
def matches?(time)

      time = Time.at(time) unless time.kind_of?(Time)

      time = @timezone.utc_to_local(time.getutc) if @timezone

      return false unless sub_match?(time, :sec, @seconds)
      return false unless sub_match?(time, :min, @minutes)
      return false unless sub_match?(time, :hour, @hours)
      return false unless date_match?(time)
      true
    end
582399
function formatTimeString_(time, endTime) {
  var ret = '';
  if (time) {
    ret += (time.getTime() - time.getTimezoneOffset() * 60000);
  }
  if (endTime) {
    ret += ', ' + (endTime.getTime() - endTime.getTimezoneOffset() * 60000);
  }
  return ret;
}
628891
def strftime(date_time=None, time_format=None):
        
        if not date_time:
            datetime_now = datetime.now()
        else:
            datetime_now = date_time
        if not time_format:
            time_format = '%Y/%m/%d %H:%M:%S'
        return datetime.strftime(datetime_now, time_format)