Helper to avoid duplicating milliseconds to secs/usecs in a few places

@param Integer millisecond timeout
@return Boolean
335020
private function set_ms_timeout($timeoutMs) {
        if (!$this->_sock) {
            return false;
        }
        return stream_set_timeout($this->_sock, floor($timeoutMs / 1000), ($timeoutMs % 1000) * 1000);
    }
978184
protected boolean hasTimeOutHeader() {

        boolean result = false;
        String timeoutValStr = this.request.getHeader(RestMessageHeaders.X_VOLD_REQUEST_TIMEOUT_MS);
        if(timeoutValStr != null) {
            try {
                this.parsedTimeoutInMs = Long.parseLong(timeoutValStr);
                if(this.parsedTimeoutInMs < 0) {
                    RestErrorHandler.writeErrorResponse(messageEvent,
                                                        HttpResponseStatus.BAD_REQUEST,
                                                        "Time out cannot be negative ");

                } else {
                    result = true;
                }
            } catch(NumberFormatException nfe) {
                logger.error("Exception when validating request. Incorrect timeout parameter. Cannot parse this to long: "
                                     + timeoutValStr,
                             nfe);
                RestErrorHandler.writeErrorResponse(this.messageEvent,
                                                    HttpResponseStatus.BAD_REQUEST,
                                                    "Incorrect timeout parameter. Cannot parse this to long: "
                                                            + timeoutValStr);
            }
        } else {
            logger.error("Error when validating request. Missing timeout parameter.");
            RestErrorHandler.writeErrorResponse(this.messageEvent,
                                                HttpResponseStatus.BAD_REQUEST,
                                                "Missing timeout parameter.");
        }
        return result;
    }
1232968
public function getTotalTimeoutMs()
    {
        $field = EnumRequestOption::TOTAL_TIMEOUT_MS;
        return isset($this->options[$field]) ? $this->options[$field] : 0;
    }
1371105
function set_timeout($timeout) {
        if (!is_integer($timeout)) {
            if (is_numeric($timeout)) {
                $this->timeout = (integer)$timeout;
                return true;
            }
            return false;
        }
        $this->timeout = $timeout;
        return true;
    }
137696
public static function setTimeout($timeout = 60) {
        if (!is_int($timeout) || $timeout < 0) {
            return false;
        }

        self::$timeout = $timeout;
        return true;
    }
1308377
protected function getMicrotime(): float
    {
        list ($uSec, $sec) = \explode(' ', \microtime());
        return ((float)$uSec + (float)$sec);
    }
820097
function milliseconds( $dp = null ){
	 	if( $this->is_running() ){
		 	$now = microtime( false );
		}
		else {
			$now = $this->stopped;
		}
		$started = self::parse_microtime( $this->started );
		$stopped = self::parse_microtime( $now );
		$ms = $stopped - $started;
		if( ! is_null($dp) ){
			$mult = pow( 10, $dp );
			$ms = round( $mult * $ms ) / $mult;
		}
		return $ms;
	 }
1356259
public function timeout($timeout = null)
    {
        if ($timeout !== null) {
            $this->lastTimeout = $timeout;
        }
        $this->ev->add($this->lastTimeout / 1e6);
    }
489536
private static int initializeTimeout() {
//        Integer tmp = java.security.AccessController.doPrivileged(
//          new GetIntegerAction("com.sun.security.crl.timeout"));
        Integer tmp = Integer.getInteger("com.sun.security.crl.timeout");
        if (tmp == null || tmp < 0) {
            return DEFAULT_CRL_CONNECT_TIMEOUT;
        }
        // Convert to milliseconds, as the system property will be
        // specified in seconds
        return tmp * 1000;
    }
744473
public function isTimeout()
    {
        if($resource = $this->getResource())
        {
            $data = stream_get_meta_data($resource);
            return (bool) $data['timed_out'];

        }

        return false;
    }
670336
function _check_timeout($fp)
    {
        if ($this->read_timeout > 0) {
            $fp_status = socket_get_status($fp);
            if ($fp_status["timed_out"]) {
                $this->timed_out = true;
                return true;
            }
        }
        return false;
    }
351263
@Override
    void set_timeout_millis(final int timeout, final boolean fwd) throws DevFailed {
	try {
	    proxy.set_timeout_millis(timeout);
	} catch (final DevFailed df) {
	    throw df;
	} catch (final Exception e) {
	    final DevError[] errors = new DevError[1];
	    errors[0] = new DevError();
	    errors[0].severity = ErrSeverity.ERR;
	    errors[0].reason = "unknown exception caught";
	    errors[0].desc = "unknown error";
	    errors[0].origin = "GroupDeviceElemnt.set_indidual_timeout_millis";
	    final DevFailed ex = new DevFailed(errors);
	    throw ex;
	}
    }
434091
public function block($seconds, $callback = null)
    {
        $starting = $this->currentTime();

        while (! $this->acquire()) {
            usleep(250 * 1000);

            if ($this->currentTime() - $seconds >= $starting) {
                throw new LockTimeoutException;
            }
        }

        if (is_callable($callback)) {
            try {
                return $callback();
            } finally {
                $this->release();
            }
        }

        return true;
    }
1003161
private static int initializeTimeout() {
//        Integer tmp = java.security.AccessController.doPrivileged(
//                new GetIntegerAction("com.sun.security.ocsp.timeout"));
        Integer tmp = Integer.getInteger("com.sun.security.ocsp.timeout");
        if (tmp == null || tmp < 0) {
            return DEFAULT_CONNECT_TIMEOUT;
        }
        // Convert to milliseconds, as the system property will be
        // specified in seconds
        return tmp * 1000;
    }
804052
public function set(int $timeoutMinutes) : bool
    {
        if ($this->isLocked()) {
            return false;
        }
        $this->setLock($timeoutMinutes);
        return true;
    }
1241930
static public function isValidTime($hour, $min, $sec, $hs24 = true)
    {
        if ($hs24 && ($hour < 0 || $hour > 23) || !$hs24 && ($hour < 1 || $hour > 12)) return false;
        if ($min > 59 || $min < 0) return false;
        if ($sec > 59 || $sec < 0) return false;
        return true;
    }
48064
@Nonnull
  public static EChange setConnectionTimeoutMilliSecs (final long nMilliSecs)
  {
    return s_aRWLock.writeLocked ( () -> {
      if (s_nConnectionTimeoutMilliSecs == nMilliSecs)
        return EChange.UNCHANGED;
      if (nMilliSecs <= 0)
        LOGGER.warn ("You are setting an indefinite connection timeout for the mail transport api: " + nMilliSecs);
      s_nConnectionTimeoutMilliSecs = nMilliSecs;
      return EChange.CHANGED;
    });
  }