Preliminary duration value parser

    strict=True (by default) raises StrictnessError if either hours,
    minutes or seconds in duration value exceed allowed values
335019
def _parse(value, strict=True):
    
    pattern = r'(?:(?P<hours>\d+):)?(?P<minutes>\d+):(?P<seconds>\d+)'
    match = re.match(pattern, value)
    if not match:
        raise ValueError('Invalid duration value: %s' % value)
    hours = safe_int(match.group('hours'))
    minutes = safe_int(match.group('minutes'))
    seconds = safe_int(match.group('seconds'))

    check_tuple((hours, minutes, seconds,), strict)

    return (hours, minutes, seconds,)
1370785
def expected_duration(self, expected_duration):
        

        if expected_duration is None:
            raise ValueError("Invalid value for `expected_duration`, must not be `None`")
        if len(expected_duration) < 1:
            raise ValueError("Invalid value for `expected_duration`, length must be greater than or equal to `1`")

        self._expected_duration = expected_duration
882670
def time_for(value)
      if value.is_a? Numeric
        Time.at value
      elsif value.respond_to? :to_s
        Time.parse value.to_s
      else
        value.to_time
      end
    rescue ArgumentError => boom
      raise boom
    rescue Exception
      raise ArgumentError, "unable to convert #{value.inspect} to a Time object"
    end
809865
def _parse_time(self, value):
        
        try:
            # Default time unit is a second, we should convert it to milliseconds.
            return int(value) * 1000
        except ValueError:
            # Try to parse if we are unlucky to cast value into int.
            m = self.time_format.match(value)
            if not m:
                raise ValueError("Could not parse time represented by '{t}'".format(t=value))
            time = int(m.group('time'))
            if m.group('units') != 'ms':
                time *= 1000
            return time
1130731
def value_validate(self, value):
        
        if not isinstance(value, datetime.datetime):
            raise tldap.exceptions.ValidationError("is invalid date time")
566757
def max_duration(self,value):
		
		if not value is None:
			if not type(value) in [float, int]:
				raise TypeError("max_duration needs to be specified as a number")
			if value<1.0:
				raise ValueError("max_duration needs to be greater than 1.0")
			value = float(value)
		self.__max_duration = value
29605
def _after_valid_time_range(self):
        
        if self.end_time is not None:
            try:
                if self.time > self.end_time:
                    return True
            except TypeError:
                return False
        return False
1203709
def __validate_datetime_string(self):
        

        try:
            try:
                StrictVersion(self._value)
                raise TypeConversionError(
                    "invalid datetime string: version string found {}".format(self._value)
                )
            except ValueError:
                pass
        except TypeError:
            raise TypeConversionError("invalid datetime string: type={}".format(type(self._value)))
466857
def certify_time(value, required=True):
    
    if certify_required(
        value=value,
        required=required,
    ):
        return

    if not isinstance(value, time):
        raise CertifierTypeError(
            message="expected timestamp (time), but value is of type {cls!r}".format(
                cls=value.__class__.__name__),
            value=value,
            required=required,
        )
263290
def read_timeout=(value)
      fail ArgumentError, "must be an integer or float" unless value && (value.is_a?(Integer) || value.is_a?(Float))
      @read_timeout = value
    end
763696
def _parse_expires(expires):
    
    # none is used to signify positive infinity
    if expires is None or expires in ('never', 'infinity'):
        return 'infinity'

    try:
        return dateutil.parser.parse(unicode(expires))
    except ValueError as exc:
        pass

    try:
        # use parsedatetime for "human readable" time specs
        exp = pdt.parse(expires)[0]
        # and convert to datetime
        return datetime.datetime.fromtimestamp(time.mktime(exp))
    except ValueError as exc:
        pass

    raise NipapValueError("Invalid date specification for expires")
583961
def init_timer(self, max_value):
    
    self.__max_value = max_value
    self.__prev_tick = time.time()
    self.__unit_per_sec = 0
    self.__unit_per_sec_prev = 0
1326764
def execution_time(self, value):
        
        if value:
            self._execution_time = parse(value) if isinstance(value, type_check) else value
293776
def _parse_time(self, time):
        """"""
        if time is None:
            return None

        if isinstance(time, dict):
            if 'column' not in time:
                raise ValueError("`time` must include a 'column' key/value")
            time_column = time['column']
            time_options = time
        elif isinstance(time, str):
            time_column = time
            time_options = {}
        else:
            raise ValueError(
                '`time` should be a column name or dictionary of '
                'styling options.')

        self.style_cols[time_column] = None
        time = {
            'column': time_column,
            'method': 'count',
            'cumulative': False,
            'frames': 256,
            'duration': 30,
            'trails': 2,
        }
        time.update(time_options)
        return time
385289
def check_time(value):
    """"""
    try:
        h, m = value.split(':')
        h = int(h)
        m = int(m)
        if h >= 24 or h < 0:
            raise ValueError
        if m >= 60 or m < 0:
            raise ValueError
    except ValueError:
        raise TimeDefinitionError("Invalid definition of time %r" % value)
1080586
def jsonify_timedelta(value):
    

    assert isinstance(value, datetime.timedelta)

    # split seconds to larger units
    seconds = value.total_seconds()
    minutes, seconds = divmod(seconds, 60)
    hours, minutes = divmod(minutes, 60)
    days, hours = divmod(hours, 24)

    days, hours, minutes = map(int, (days, hours, minutes))
    seconds = round(seconds, 6)

    # build date
    date = ''
    if days:
        date = '%sD' % days

    # build time
    time = u'T'

    # hours
    bigger_exists = date or hours
    if bigger_exists:
        time += '{:02}H'.format(hours)

    # minutes
    bigger_exists = bigger_exists or minutes
    if bigger_exists:
        time += '{:02}M'.format(minutes)

    # seconds
    if seconds.is_integer():
        seconds = '{:02}'.format(int(seconds))
    else:
        # 9 chars long w/leading 0, 6 digits after decimal
        seconds = '%09.6f' % seconds
        # remove trailing zeros
        seconds = seconds.rstrip('0')

    time += '{}S'.format(seconds)

    return u'P' + date + time
643024
def _check_time_range(time_range, now):
    '''
    
    '''
    if _TIME_SUPPORTED:
        _start = dateutil_parser.parse(time_range['start'])
        _end = dateutil_parser.parse(time_range['end'])

        return bool(_start <= now <= _end)
    else:
        log.error('Dateutil is required.')
        return False