Convert string time to seconds.

        Examples
        00:14:23
        00:13:40
        00:00:21
        00:00:13
        00:00:49
        1d11h
        1d17h
        1w0d
        8w5d
        1y28w
        never
542282
def bgp_time_conversion(bgp_uptime):
        
        bgp_uptime = bgp_uptime.strip()
        uptime_letters = set(['w', 'h', 'd'])

        if 'never' in bgp_uptime:
            return -1
        elif ':' in bgp_uptime:
            times = bgp_uptime.split(":")
            times = [int(x) for x in times]
            hours, minutes, seconds = times
            return (hours * 3600) + (minutes * 60) + seconds
        # Check if any letters 'w', 'h', 'd' are in the time string
        elif uptime_letters & set(bgp_uptime):
            form1 = r'(\d+)d(\d+)h'  # 1d17h
            form2 = r'(\d+)w(\d+)d'  # 8w5d
            form3 = r'(\d+)y(\d+)w'  # 1y28w
            match = re.search(form1, bgp_uptime)
            if match:
                days = int(match.group(1))
                hours = int(match.group(2))
                return (days * DAY_SECONDS) + (hours * 3600)
            match = re.search(form2, bgp_uptime)
            if match:
                weeks = int(match.group(1))
                days = int(match.group(2))
                return (weeks * WEEK_SECONDS) + (days * DAY_SECONDS)
            match = re.search(form3, bgp_uptime)
            if match:
                years = int(match.group(1))
                weeks = int(match.group(2))
                return (years * YEAR_SECONDS) + (weeks * WEEK_SECONDS)
        raise ValueError("Unexpected value for BGP uptime string: {}".format(bgp_uptime))
621163
def SecondsToZuluTS(secs=None):
	

	if not secs:  secs = int(time.time())

	return(datetime.utcfromtimestamp(secs).strftime("%Y-%m-%dT%H:%M:%SZ"))
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';
		}
	}
316203
def _timedelta_to_seconds(td):
        
        if isinstance(td, numbers.Real):
            td = datetime.timedelta(seconds=td)
        return td.total_seconds()
135126
def to_seconds(value, time_unit):
        
        if isinstance(value, bool):
            # bool is a subclass of int. Don't let bool and float multiplication.
            raise TypeError
        return float(value) * time_unit
734059
def time_to_seconds(x):
    """"""
    if isinstance(x, time):
        return ((((x.hour * 60) + x.minute) * 60 + x.second) * 10**6 +
                x.microsecond) / 10**6

    if is_str(x):
        return x
    # Clamp to valid time
    return x and max(0, min(x, 24 * 3600 - 10**-6))
267297
def fmt_second(time_total):
    

    def _ck(t):
        return t < 10 and "0%s" % t or t

    times = int(time_total)
    h = times / 3600
    m = times % 3600 / 60
    s = times % 3600 % 60
    return "%s:%s:%s" % (_ck(h), _ck(m), _ck(s))
1342838
def seconds_to_hms_verbose(t):
    
    hours = int((t / 3600))
    mins = int((t / 60) % 60)
    secs = int(t % 60)
    return ' '.join([
        (hours + ' hour' + ('s' if hours > 1 else '')) if hours > 0 else '',
        (mins + ' minute' + ('s' if mins > 1 else '')) if mins > 0 else '',
        (secs + ' second' + ('s' if secs > 1 else '')) if secs > 0 else ''
    ])
307112
def CopyToDateTimeString(self):
    
    if self._number_of_seconds is None:
      return None

    return '{0:04d}-{1:02d}-{2:02d} {3:02d}:{4:02d}:{5:02d}'.format(
        self._time_elements_tuple[0], self._time_elements_tuple[1],
        self._time_elements_tuple[2], self._time_elements_tuple[3],
        self._time_elements_tuple[4], self._time_elements_tuple[5])
130225
function (time, n) {
    time = Number(time) || 0;
    n = n || 2;

    if (n === 2) {
      time = time < 10 ? time + '0' : time;
    } else if (n === 3) {
      time = time < 10
        ? time + '00'
        : time < 100
          ? time + '0'
          : time;
    }

    return String(time);
  }
957114
def seconds_to_text(secs):
    
    hours = (secs)//3600
    minutes = (secs - hours*3600)//60
    seconds = secs - hours*3600 - minutes*60
    return "%02d:%02d:%02d" % (hours, minutes, seconds)
21197
def parse_seconds(value):
        '''
        
        '''
        svalue = str(value)
        colons = svalue.count(':')
        if colons == 2:
            hours, minutes, seconds = [int(v) for v in svalue.split(':')]
        elif colons == 1:
            hours, minutes = [int(v) for v in svalue.split(':')]
            seconds = 0
        elif colons == 0:
            hours = 0
            minutes = 0
            seconds = int(svalue)
        else:
            raise ValueError('Must be in seconds or HH:MM:SS format')
        return Seconds.from_hms(hours, minutes, seconds)
1033289
def humanTime(seconds):
  '''
  
  '''
  intervals = ['days', 'hours', 'minutes', 'seconds']
  x = deltaTime(seconds=seconds)
  return ' '.join('{} {}'.format(getattr(x, k), k) for k in intervals if getattr(x, k))
767883
def to_seconds(value, strict=True, force_int=True):
    
    if isinstance(value, int):
        return value  # assuming it's seconds
    elif isinstance(value, timedelta):
        seconds = value.total_seconds()
        if force_int:
            seconds = int(round(seconds))
        return seconds
    elif isinstance(value, str):
        hours, minutes, seconds = _parse(value, strict)
    elif isinstance(value, tuple):
        check_tuple(value, strict)
        hours, minutes, seconds = value
    else:
        raise TypeError(
            'Value %s (type %s) not supported' % (
                value, type(value).__name__
            )
        )

    if not (hours or minutes or seconds):
        raise ValueError('No hours, minutes or seconds found')

    result = hours*3600 + minutes*60 + seconds
    return result
1316603
def time(ctx, hours, minutes, seconds):
    
    return _time(conversions.to_integer(hours, ctx), conversions.to_integer(minutes, ctx), conversions.to_integer(seconds, ctx))
1196510
def time_to_seconds(t):
    
    l = list(map(int, t.split(':')))
    return sum(n * sec for n, sec in zip(l[::-1], (1, 60, 3600)))
457365
def get_readable_time_string(seconds):
    """"""
    seconds = int(seconds)
    minutes = seconds // 60
    seconds = seconds % 60
    hours = minutes // 60
    minutes = minutes % 60
    days = hours // 24
    hours = hours % 24

    result = ""
    if days > 0:
        result += "%d %s " % (days, "Day" if (days == 1) else "Days")
    if hours > 0:
        result += "%d %s " % (hours, "Hour" if (hours == 1) else "Hours")
    if minutes > 0:
        result += "%d %s " % (minutes, "Minute" if (minutes == 1) else "Minutes")
    if seconds > 0:
        result += "%d %s " % (seconds, "Second" if (seconds == 1) else "Seconds")

    return result.strip()