munge time-like parameter into millisecond number '0.4s' -> 40
554030
function getMilliseconds( time ) {
  if ( typeof time == 'number' ) {
    return time;
  }
  var matches = time.match( /(^\d*\.?\d*)(\w*)/ );
  var num = matches && matches[1];
  var unit = matches && matches[2];
  if ( !num.length ) {
    return 0;
  }
  num = parseFloat( num );
  var mult = msUnits[ unit ] || 1;
  return num * mult;
}
13010
def granularity_to_time(s):
    
    mfact = {
        'S': 1,
        'M': 60,
        'H': 3600,
        'D': 86400,
        'W': 604800,
    }
    try:
        f, n = re.match("(?P<f>[SMHDW])(?:(?P<n>\d+)|)", s).groups()
        n = n if n else 1
        return mfact[f] * int(n)

    except Exception as e:
        raise ValueError(e)
908454
def prepare_time_millis(data, schema):
    """"""
    if isinstance(data, datetime.time):
        return int(
            data.hour * MLS_PER_HOUR + data.minute * MLS_PER_MINUTE
            + data.second * MLS_PER_SECOND + int(data.microsecond / 1000))
    else:
        return data
115557
def _seconds_as_string(seconds):
    
    TIME_UNITS = [('s', 60), ('m', 60), ('h', 24), ('d', None)]
    unit_strings = []
    cur = max(int(seconds), 1)
    for suffix, size in TIME_UNITS:
        if size is not None:
            cur, rest = divmod(cur, size)
        else:
            rest = cur
        if rest > 0:
            unit_strings.insert(0, '%d%s' % (rest, suffix))
    return ' '.join(unit_strings)
600104
def nsamples_to_minsec(x, pos):
    '''
    '''
    h, m, s = hourminsec(x/16.0)
    return '{:2.0f}′ {:2.1f}″'.format(m+(h*60), s)
1063170
def now_millis(absolute=False) -> int:
  """"""
  millis = int(time.time() * 1e3)
  if absolute:
    return millis
  return millis - EPOCH_MICROS // 1000
252075
def ms_to_timestamp(ms):
    """'"""
    # XXX throw on overflow/underflow?
    if ms < 0: ms = 0
    if ms > MAX_REPRESENTABLE_TIME: ms = MAX_REPRESENTABLE_TIME
    h, m, s, ms = ms_to_times(ms)
    return "%01d:%02d:%02d.%02d" % (h, m, s, ms//10)
1242040
def _microtime():
    '''
    
    '''
    val1, val2 = math.modf(time.time())
    val2 = int(val2)
    return '{0:f}{1}'.format(val1, val2)
904722
def TimeToSecondsSinceMidnight(time_string):
  """"""
  m = re.match(r'(\d{1,3}):([0-5]\d):([0-5]\d)$', time_string)
  # ignored: matching for leap seconds
  if not m:
    raise errors.Error('Bad HH:MM:SS "%s"' % time_string)
  return int(m.group(1)) * 3600 + int(m.group(2)) * 60 + int(m.group(3))
808562
def ToTimedelta(self):
    """"""
    return timedelta(
        seconds=self.seconds, microseconds=_RoundTowardZero(
            self.nanos, _NANOS_PER_MICROSECOND))
499707
function secondsToTimeParam(seconds) {
	var h = Math.floor(seconds / 3600);
	var m = Math.floor((seconds / 60) % 60);
	var s = seconds % 60;
	var param = '';

	if (h > 0) {
		param += h + 'h';
	}

	if (m > 0) {
		param += m + 'm';
	}

	if (s > 0) {
		param += s + 's';
	}

	return param;
}
781511
def wtime_to_minutes(time_string):
    ''' 

    '''
    hours, mins, seconds = time_string.split(':')
    return int(hours) * 60 + int(mins) + 1
903610
def seconds(value)
      result = if value >= 60 * 60
                 "#{value / 60 / 60}:#{Kernel.format('%02i', (value / 60) % 60)}"
               else
                 (value / 60).to_s
               end

      result + ':' + Kernel.format('%02i', value % 60)
    end
1179078
def _muck_w_date(record):
    """"""
    # minute 60 is actually minute 0?
    temp_d = datetime.datetime(int(record['Year']), int(record['Month']),
                               int(record['Day']), int(record['Hour']) % 24,
                               int(record['Minute']) % 60)
    d_off = int(record['Hour'])//24   # hour 24 is actually hour 0
    if d_off > 0:
        temp_d += datetime.timedelta(days=d_off)
    return temp_d
1154752
def seconds_to_time(x):
    """"""
    t = int(x * 10**6)
    ms = t % 10**6
    t = t // 10**6
    s = t % 60
    t = t // 60
    m = t % 60
    t = t // 60
    h = t
    return time(h, m, s, ms)
882714
def parse(s, return_type=int):
    '''
    
    '''
    RE_DAY = r'([0-9]+)d(ay)?'
    RE_HOUR = r'([0-9]+)h(our)?'
    RE_MINUTE = r'([0-9]+)m(in(ute)?)?'
    RE_SECOND = r'([0-9]+)(s(ec(ond)?)?)?'

    def _parse_time_with_unit(s):
        retval = 0
        md = re.match(RE_DAY, s)
        mh = re.match(RE_HOUR, s)
        mm = re.match(RE_MINUTE, s)
        ms = re.match(RE_SECOND, s)
        if md:
            retval = 86400 * int(md.group(1))
        elif mh:
            retval = 3600 * int(mh.group(1))
        elif mm:
            retval = 60 * int(mm.group(1))
        elif ms:
            retval = int(ms.group(1))
        return retval

    if isinstance(s, (type(None), int, float)):
        return s

    if s[-1] in '0123456789':
        s += 's'

    m = re.match(r'^(%s)?(%s)?(%s)?(%s)?$' % (RE_DAY, RE_HOUR,
                                              RE_MINUTE, RE_SECOND),
                 s)
    if not m:
        raise ParseError('invalid string: "%s"' % s)

    times = [x for x in m.groups() if isinstance(x, str) and
             re.match(r'[0-9]+[a-z]+', x)]
    seconds = sum(_parse_time_with_unit(z) for z in times)

    if return_type is int:
        return seconds
    elif return_type is timedelta:
        return timedelta(seconds=seconds)
    else:
        raise TypeError('return_type "{}" is not supported.'.format(
            return_type.__name__))
1244835
function convertTime(value, fromUnit, toUnit)
{
    if(fromUnit != toUnit && value !== 0)
    {
        return value * (toUnit == 's'? 0.001 : 1000);
    }
    return value;
}