Previous: , Up: posix time   [Index]


4.18.7 Date and time functions

Function: clock

Interface to the C function clock(), (libc)clock. If successful return an exact integer representing the CPU time for the calling process expressed in clock ticks; if the clock time is not available return false.

Function: times

Interface to the C function times(), (libc)times. If successful return an instance of struct-tms representing the current processor time, else return false.

Function: time

Interface to the C function time(), (libc)time. If successful return the calendar time as an exact integer, else return false.

Function: gettimeofday

Interface to the C function gettimeofday(), (libc)gettimeofday. Acquire the current time. If successful return an instance of struct-timeval, else raise an exception.

Function: localtime time

Interface to the C function localtime(), (libc)localtime. Given an exact integer time representing the local time as returned by the time function: build and return an instance of struct-tm representing the same time in human readable form; if an error occurs raise an exception.

Function: gmtime time

Interface to the C function gmtime(), (libc)gmtime. Given an exact integer time representing the UTC time as returned by the time function: build and return an instance of struct-tm representing the same time in human readable form; if an error occurs raise an exception.

Function: timelocal tm

Interface to the C function timelocal(), (libc)timelocal. Given a reference to a struct-rm, tm, representing a local broken time, convert it into a time value as returned by time(). If successful return an exact integer representing the time value, else raise an exception.

Function: timegm tm

Interface to the C function timegm(), (libc)timegm. Given a reference to a struct-rm, tm, representing a UTC broken time, convert it into a time value as returned by time(). If successful return an exact integer representing the time value, else raise an exception.

Function: strftime template tm
Function: strftime/string template tm

Interface to the C function strftime(), (libc)strftime. Given a bytevector template holding an ASCII coded format string and a struct-tm instance tm: build a formatted time string; the resulting time string can be at most 4096 bytes wide. If successful strftime returns a bytevector holding the time string in ASCII coding and strftime/string returns a Scheme string, else raise an exception.

Function: nanosleep secs nsecs

Interface to the C function nanosleep(), (libc)nanosleep. Halt the current process for the specified amount of time.

The count of seconds secs must be an exact integer in the range [0, 2^32); the count of nanoseconds nsecs must be an exact integer in the range [0, 999999999].

If successful and the requested time is elapsed: return a pair whose car is false and whose cdr is false. If successful and the sleeping was interrupted by an interprocess signal: return a pair whose car is an exact integer representing the count of remaining seconds and whose cdr is an exact integer representing the count of remaining nanoseconds. If an error occurs an exception is raised.

Function: setitimer which itimerval

Interface to the C function setitimer(), (libc)setitimer. Set the timer specified by which according to itimerval. If successful return unspecified values, else raise an exception.

which must be a fixnum representing one of the constants: ITIMER_REAL, ITIMER_VIRTUAL, ITIMER_PROF.

itimerval must be an instance of struct-itimerval.

Function: getitimer which

Interface to the C function getitimer(), (libc)getitimer. Build and return a new struct-itimerval representing the current timer.

Function: alarm seconds

Interface to the C function alarm(), (libc)alarm. Set the real–time timer to expire in seconds. Return an exact integer representing how many seconds remain before the previous alarm would have been sent.

The following are the real–time clock functions. They are available when Vicare is linked with the rt library.

NOTE On GNU+Linux systems the argument clock-id to the clock-* functions can be one among:

CLOCK_REALTIME
CLOCK_MONOTONIC                 CLOCK_MONOTONIC_RAW
CLOCK_PROCESS_CPUTIME_ID        CLOCK_THREAD_CPUTIME_ID

or a value returned by clock-getcpuclockid. The code assumes that clock identifiers of type clockid_t can be safely converted to C language long values.

Function: clock-getres clock-id time

Interface to the C function clock-getres(), see the manual page clock-getres(2). Find the resolution of the clock selected by the fixnum clock-id and store it in time, which must be an instance of struct-timespec. If successful return time itself, else raise an exception.

Function: clock-gettime clock-id time

Interface to the C function clock-gettime(), see the manual page clock-gettime(2). Retrieve the time of the clock selected by the fixnum clock-id and store it in time, which must be an instance of struct-timespec. If successful return time itself, else raise an exception.

Function: clock-settime clock-id time

Interface to the C function clock-settime(), see the manual page clock-settime(2). Set the time of the clock selected by the fixnum clock-id acquiring it from time, which must be an instance of struct-timespec. If successful return time itself, else raise an exception.

Function: clock-getcpuclockid pid

Interface to the C function clock_getcpuclockid(), see the manual page clock_getcpuclockid(3). Obtain the identifier of a process’ CPU–time clock; if successful return an exact integer representing the clock identifier, else raise an exception. pid must be a fixnum representing the process identifier (PID).


Previous: , Up: posix time   [Index]