Get a suitable time string
        ("ss", "mm:ss", "hh:mm:ss"),
        according to the maximum time.

        :param int value: the time value
        :rtype: string
554327
def _time_string(self, value):
        
        if self.max_time < 60:
            return "%02d" % (value)
        elif self.max_time < 3600:
            mm = value // 60
            ss = value - mm * 60
            return "%02d:%02d" % (mm, ss)
        hh = value // 3600
        mm = (value - hh * 3600) // 60
        ss = (value - hh * 3600 - mm * 60)
        return "%02d:%02d:%02d" % (hh, mm, ss)
1352129
private int getTimeX(double value) {
		double d = left + (((right - left) * value) / (maxTime - minTime));
		return (int) d;
	}
124960
def _restriction_string(self):
        

        if self.has_minimum:
            string = 'at least '
            value = self._minimum
        elif self.has_maximum:
            string = 'at most '
            value = self._maximum
        elif self.has_exact:
            string = ''
            value = self._exact

        return (string + '{} {}').format(
            value,
            pluralize('time', value)
        )
1326764
def execution_time(self, value):
        
        if value:
            self._execution_time = parse(value) if isinstance(value, type_check) else value
497930
def datetime(value):
    
    if isinstance(value, (date, builtin_datetime)):
        pass
    elif value < 10000000000:
        value = unix2datetime(value)
    else:
        value = milli2datetime(value)

    return datetime2string(value, "%Y-%m-%d %H:%M:%S.%f").rstrip(".000000").rstrip("000")
222181
def valueFromString(self, value, context=None):
        
        if value in ('today', 'now'):
            return datetime.date.today()
        elif dateutil_parser:
            return dateutil_parser.parse(value).date()
        else:
            time_struct = time.strptime(value, self.defaultFormat())
            return datetime.date(time_struct.tm_year,
                                 time_struct.tm_month,
                                 time_struct.tm_day)
1134285
def strftime(self, dtime, format):      # pylint: disable=redefined-builtin
        
        format = self.STRFTIME_FORMATS.get(format + "_FORMAT", format)
        if six.PY2 and isinstance(format, six.text_type):
            format = format.encode("utf8")
        timestring = dtime.strftime(format)
        if six.PY2:
            timestring = timestring.decode("utf8")
        return timestring
890246
def _resolve_time(value):
  '''
  
  '''
  if value is None or isinstance(value,(int,long)):
    return value

  if NUMBER_TIME.match(value):
    return long(value)

  simple = SIMPLE_TIME.match(value)
  if SIMPLE_TIME.match(value):
    multiplier = long( simple.groups()[0] )
    constant = SIMPLE_TIMES[ simple.groups()[1] ]
    return multiplier * constant

  if value in GREGORIAN_TIMES:
    return value

  raise ValueError('Unsupported time format %s'%value)
547834
def to_timestamp(self, value):
        
        if isinstance(value, (six.integer_types, float, six.string_types)):
            try:
                return float(value)
            except ValueError:
                value = self.datetime_str_to_datetime(value)

        if isinstance(value, datetime.datetime):
            return self._datetime_to_timestamp(value)

        if value is None:
            try:
                return float(self.default)
            except:
                return 0.0

        raise exceptions.ValidationError(
            "Unable to convert value: '%s' to timestamp" % value,
            code="invalid_timestamp"
        )
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
1271968
def timetopythonvalue(time_val):
    ""
    if isinstance(time_val, sequence):
        return map(timetopythonvalue, time_val)
    elif isinstance(time_val, numeric):
        return datetime.datetime(*(time.gmtime(time_val))[:6])
    elif isinstance(time_val, numeric):
        values = []
        try:
            values = map(long, time_val.split(","))
        except:
            pass
        if values:
            return map(timetopythonvalue, values)
    raise ValueError(repr(time_val))
5730
def time_sp(self):
        
        self._time_sp, value = self.get_attr_int(self._time_sp, 'time_sp')
        return value
850153
def convert_time(self, time):
        
        time_string = str(datetime.timedelta(seconds=int(time)))
        if time_string.split(':')[0] == '0':
            time_string = time_string.partition(':')[2]
        return time_string
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
626104
def unix(value):
    
    if isinstance(value, (date, builtin_datetime)):
        pass
    elif value < 10000000000:
        value = unix2datetime(value)
    else:
        value = milli2datetime(value)

    return str(datetime2unix(value))
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
95446
def parse_time(t):
    
    if isinstance(t, (str, unicode)):
        b = re_time.match(t)
        if b:
            v, unit = int(b.group(1)), b.group(2)
            if unit == 's':
                return v*1000
            elif unit == 'm':
                return v*60*1000
            elif unit == 'h':
                return v*60*60*1000
            else:
                return v
        else:
            raise TimeFormatError(t)
    elif isinstance(t, (int, long)):
        return t
    else:
        raise TimeFormatError(t)