Time
Objects of type Timeval
represent absolute time points. The time
points are internally represented using Coordinated Universal
Time(UTC)
making them location independent. The time points are internally
represented as number of microseconds since January 1st, 1970, which
is called the
epoch.
Get current time according to UTC by calling:
utc_time()
The time format is year-month-dateThour:minute:second:millisecondZ
. The ending Z
indicates UTC time, also called Greenwich Mean Time (GMT).
Get the local time by calling:
local_time()
Notice that the local time string depends on where your sa.engine server is located. As an alternative you can get a location independent local time string by calling:
local_utc_time()
The ending hh:ss
indicates the time shift in hours and minutes needed to get UTC time.
Get the current time point by calling:
now()
Constants of type Timeval
are written as |UTC-time|
.
You can create new time points by adding or subtracting seconds from time points using +
or -
, respectively:
set :t1=now();
:t1 + 1;
:t1 - 1
You can get the time in seconds between two time points by using -
, e.g.:
set :t1 = now();
set :t2 = :t1 + 2;
:t2 - :t1
The function call sleep(x)
makes the system sleep for x seconds. Try:
set :t1 = now();
sleep(0.2);
now() - :t1