The WebAbility® Network Developers - Documentation
WebAbility Site
\dominion\DB_uTime Reference

I. Structure:


- Direct Superclass:
WAClass

- Direct known subclasses:
none

II. Description:


This object is used to work with microtime. It is usefull to use microtime for programmation and process calculation that last less than a second.

The u of uTime is a representation in latin letter of the greek letter mu that symbolize the micro measure, that is 10-6. The class works with microseconds.

You can print directly the microtime:
print $uT;
This will print the microtime with a floating number, the units part are the seconds, and the decimal part are the microseconds.


2.1. Using the class:


You can directly print the microtime:
print $T;
This will print the microtime under the format of a floating number. The integer part are the unix seconds and the decimal part are the microseconds.

You may also chain the set functions for code compression:


$T = new DB_uTime();
$T->setSecond(100)->setMicrosecond(10000);



2.2. Error messages:


If you want to translate the libraries you should consider into the WAMessage XML translation file the following entries:
- DB_uTime.badinit: The initialization time is not recognized.
- DB_uTime.badutimeobject: The parameter is not a DB_uTime object.


III. Reference:


3.1. Contructor:

DB_uTime(mixed $time)
$time contains the information of the time to initialize the instance.
If $time is null, the instance will be initialized with zero (no time).
If $time is 'N', it will be initialized with the actual time (now).
If $time is a DB_uTime object, it will be copied in the new instance.

3.2. Attributes:

none

3.3. Methods:


public DB_uTime getClone()
Returns a clone copy of this microtime with the same timestamp. This method is the same as PHP clone operator:
$T = new DB_uTime();
$U = clone $T;
$U = $T->getClone(); // identical to clone

public void initTime(mixed $time)
$time contains the information of the time to initialize the instance.
If $time is null, the instance will be initialized with zero (no time).
If $time is 'N', it will be initialized with the actual time (now).
If $time is a DB_uTime object, it will be copied in the new instance.

public void copy(DB_uTime $time)
Will copy the value of $time into this time instance.
$time: instance of DB_uTime.
If $time is not an instance of DB_uTime, an exception will be thrown: DB_uTimeException.
Returns the object reference to chain the methods.

public void setNow()
Set the instance to the current timestamp.
Returns the object reference to chain the methods.

public void setSecond(integer $second)
Sets the quantity of seconds to the instance.
  • $second: Integer. The quantity of seconds to to assign. If the value is not an integer, only the integer part will be used.

public void setMicrosecond(integer $microsecond)
Sets the quantity of microseconds to the instance.
  • $microsecond: Integer, from 0 to 999999. The quantity of microseconds to assign. If the value is not an integer, only the integer part will be used.

public void setTime(float $time)
Sets the timestamp to the instance.
  • $time: Float. The integer part are the seconds, The decimal part are the microseconds (up to a 10-6 resolution).

public integer getSecond()
Returns the seconds part of the time into the instance.

public integer getMicrosecond()
Returns the microseconds part of the time into the instance.

public float getTime()
Returns the time value as a float format. Integer part are the seconds, decimal parts are the microseconds with a 10-6 resoluction.

public void startChronometer()
Start to count time from this moment with this instance. It is equivalent to call setNow() method.

public float getChronometer()
Return the time that have passed since the last startChronometer() call, or from the time in the instance, under the form of a floating number.
It is the difference between now() and the time into the instance.

public string __toString()
Returns the time under a string that is the floating number time with 6 decimals.