class Timeval (View source)

Class Timeval

Methods

__construct(int $usec)

Constructs a new instance of the Timeval class

add(Timeval $other)

Adds another Timeval to this one and returns the sum. Calculations saturate at infinities.

static int
compare(Timeval $a, Timeval $b)

Return negative, 0, or positive according to whether a < b, a == b, or a > b respectively.

static Timeval
infFuture()

Returns the infinite future time value as a timeval object

static Timeval
infPast()

Returns the infinite past time value as a timeval object

static Timeval
now()

Returns the current time as a timeval object

static bool
similar(Timeval $a, Timeval $b, Timeval $threshold)

Checks whether the two times are within $threshold of each other

sleepUntil()

Sleep until this time, interpreted as an absolute timeout

subtract(Timeval $other)

Subtracts another Timeval from this one and returns the difference.

static Timeval
zero()

Returns the zero time interval as a timeval object

Details

__construct(int $usec)

Constructs a new instance of the Timeval class

Parameters

int $usec

The number of microseconds in the interval

Timeval add(Timeval $other)

Adds another Timeval to this one and returns the sum. Calculations saturate at infinities.

Parameters

Timeval $other

The other Timeval object to add

Return Value

Timeval

A new Timeval object containing the sum

Exceptions

InvalidArgumentException

static int compare(Timeval $a, Timeval $b)

Return negative, 0, or positive according to whether a < b, a == b, or a > b respectively.

Parameters

Timeval $a

The first time to compare

Timeval $b

The second time to compare

Return Value

int

Exceptions

InvalidArgumentException

static Timeval infFuture()

Returns the infinite future time value as a timeval object

Return Value

Timeval

Infinite future time value

static Timeval infPast()

Returns the infinite past time value as a timeval object

Return Value

Timeval

Infinite past time value

static Timeval now()

Returns the current time as a timeval object

Return Value

Timeval

The current time

static bool similar(Timeval $a, Timeval $b, Timeval $threshold)

Checks whether the two times are within $threshold of each other

Parameters

Timeval $a

The first time to compare

Timeval $b

The second time to compare

Timeval $threshold

The threshold to check against

Return Value

bool

True if $a and $b are within $threshold, False otherwise

Exceptions

InvalidArgumentException

sleepUntil()

Sleep until this time, interpreted as an absolute timeout

Timeval subtract(Timeval $other)

Subtracts another Timeval from this one and returns the difference.

Calculations saturate at infinities.

Parameters

Timeval $other

The other Timeval object to subtract

Return Value

Timeval

A new Timeval object containing the sum

Exceptions

InvalidArgumentException

static Timeval zero()

Returns the zero time interval as a timeval object

Return Value

Timeval

Zero length time interval