Name
SPVM::Sys::Time - System Calls for Time Manipulation
Description
Sys::Process class in SPVM has methods to call system calls for time manipulation.
Usage
use Sys::Time;
my $epoch = Sys::Time->time;
my $time_info_local = Sys::Time->localtime($epoch);
my $time_info_utc = Sys::Time->gmtime($epoch);
Class Methods
time
static method time : long ();
Calls time function and returns its return value.
localtime
static method localtime : Sys::Time::Tm ($time_ref : long*);
Calls localtime function and creates a Sys::Time::Tm object given its return value, and returns it.
Exceptions:
The reference of the time $time must be defined. Otherwise an exception is thrown.
gmtime
static method gmtime : Sys::Time::Tm ($time_ref : long*);
Calls gmtime function and creates a Sys::Time::Tm object given its return value, and returns it.
Exceptions:
The reference of the time $time must be defined. Otherwise an exception is thrown.
gettimeofday
static method gettimeofday : int ($tv : Sys::Time::Timeval, $tz : Sys::Time::Timezone);
Calls gmtime function and creates a Sys::Time::Timeval object given its return value, and returns it.
Exceptions:
If the gettimeofday function failed, an exception is thrown with eval_error_id set to the basic type ID of Error::System.
clock
static method clock : long ()
Calls clock function, and returns its return value.
Exceptions:
If the clock function failed, an exception is thrown with eval_error_id set to the basic type ID of Error::System.
clock_gettime
static method clock_gettime : int ($clk_id : int, $tp : Sys::Time::Timespec);
Calls clock_gettime function, and returns its return value.
See Sys::Time::Constant about constant values given to $clk_id.
Exceptions:
$tp must be defined. Otherwise an exception is thrown.
If the clock_gettime function failed, an exception is thrown with eval_error_id set to the basic type ID of Error::System.
clock_getres
static method clock_getres : int ($clk_id : int, $res : Sys::Time::Timespec);
Calls clock_getres function, and returns its return value.
See Sys::Time::Constant about constant values given to $clk_id.
Exceptions:
$res must be defined. Otherwise an exception is thrown.
If the clock_getres function failed, an exception is thrown with eval_error_id set to the basic type ID of Error::System.
setitimer
static method setitimer : int ($which : int, $new_value : Sys::Time::Itimerval, $old_value : Sys::Time::Itimerval)
Calls setitimer function, and returns its return value.
See Sys::Time::Constant about constant values given to $which.
Exceptions:
$new_value must be defined. Otherwise an exception is thrown.
If the clock_getres function failed, an exception is thrown with eval_error_id set to the basic type ID of Error::System.
In Windows the following exception is thrown with eval_error_id set to the basic type ID of Error::NotSupported class. setitimer is not supported in this system(defined(_WIN32)).
getitimer
static method getitimer : int ($which : int, $curr_value : Sys::Time::Itimerval);
Calls getitimer function, and returns its return value.
See Sys::Time::Constant about constant values given to $which.
Exceptions:
$curr_value must be defined. Otherwise an exception is thrown.
If the getitimer function failed, an exception is thrown with eval_error_id set to the basic type ID of Error::System.
In Windows the following exception is thrown with eval_error_id set to the basic type ID of Error::NotSupported class. getitimer is not supported in this system(defined(_WIN32)).
times
static method times : long ($buffer : Sys::Time::Tms);
Calls times function, and returns its return value.
Exceptions:
$tms must be defined. Otherwise an exception is thrown.
If the times function failed, an exception is thrown with eval_error_id set to the basic type ID of Error::System.
In Windows the following exception is thrown with eval_error_id set to the basic type ID of Error::NotSupported class. times is not supported in this system(defined(_WIN32)).
clock_nanosleep
static method clock_nanosleep : int ($clockid : int, $flags : int, $request : Sys::Time::Timespec, $remain : Sys::Time::Timespec);
Calls clock_nanosleep function, and returns its return value.
See Sys::Time::Constant about constant values given to $clockid and $flags.
Exceptions:
$request must be defined. Otherwise an exception is thrown.
In Mac the following exception is thrown with eval_error_id set to the basic type ID of Error::NotSupported class. clock_nanosleep is not supported in this system(__APPLE__).
nanosleep
static method nanosleep : int ($rqtp : Sys::Time::Timespec, $rmtp : Sys::Time::Timespec);
Calls nanosleep function, and returns its return value.
Exceptions:
$rqtp must be defined. Otherwise an exception is thrown.
If the nanosleep function failed, an exception is thrown with eval_error_id set to the basic type ID of Error::System.
utime
static method utime : int ($filename : string, $times : Sys::Time::Utimbuf);
Calls utime function, and returns its return value.
utimes
static method utimes : int ($filename : string, $times : Sys::Time::Timeval[]);
Calls utimes function, and returns its return value.
The utime() system call changes the access and modification times of the inode specified by filename to the actime and modtime fields of times respectively.
tzset
static method tzset : void ();
Initializes time conversion information from the environment variable TZ.
See tzset function in the POSIX branch of the Single UNIX Specification.
See Also
Copyright & License
Copyright (c) 2023 Yuki Kimoto
MIT License