Open System Services Programmer's Guide

Example 42 Using gettimeofday()
#include <sys/time.h>
#include <time.h>
#include <stdio.h>
int main(int argc, char *argv[])
{
struct timeval tv;
struct timezone tz;
/*
Read the system values for the current time and time zone.
The time is expressed in seconds and microseconds since
midnight January 1, 1970.
*/
gettimeofday(&tv, &tz);
printf("The current time is:\n%s", ctime(&tv.tv_sec));
printf("and %d microseconds after midnight January 1, 1970\n", tv.tv_usec);
printf("Daylight savings time value = %d\n", tz.tz_dsttime);
printf("Local time zone in minutes west of Greenwich = %d\n",
tz.tz_minuteswest);
return(0);
}
Table 16 OSS Time-Management Functions
Guardian NotesOSS NotesOSS Function
Does not work with Guardian TNS
processes because OSS signals cannot
be sent to a Guardian TNS process.
A SIGLIMIT signal is delivered to the
process if the function call fails.
alarm()
Sets or changes the time-out value for
an interval timer.
asctime()
Converts a date and time to a string.
Refer to ctime().
clock()
Reports processor time used.
ctime()
Converts time units.
difftime()
Computes the difference between two
calendar time values. Refer to
ctime().
Can be called only by native
processes.
ftime(3)
Gets date and time.
Can be called only by native processes.Can be called only by native
processes.
getdate()
Converts user format date and time.
Cannot be used from the Guardian
environment.
gettimeofday()
Gets date and time.
gmtime()
Converts a time value to broken-down
Coordinated Universal Time (UTC)
time. Refer to ctime().
localtime()
Converts a time value to broken-down
local time. Refer to ctime().
mktime()
170 Managing Time