GETTIMEOFDAY(2) COMMAND REFERENCE GETTIMEOFDAY(2) NAME gettimeofday, settimeofday, cfsettimeofday - get/set date and time SYNOPSIS #include <sys/time.h> gettimeofday(tp, tzp) struct timeval *tp; struct timezone *tzp; settimeofday(tp, tzp) struct timeval *tp; struct timezone *tzp; cfsettimeofday (cflag, tp, tzp) int cflag; struct timeval *tp; struct timezone *tzp; DESCRIPTION Gettimeofday returns the system's notion of the current Greenwich time and the current time zone in the structures pointed to by tp and tzp. Settimeofday sets the time, using the contents of the structures. Cfsettimeofday, in addition to setting the time, resets or computes the software correction factor for the system time-of-day clock via the cflag parameter. Acceptable values for cflag follow: TVIGNORECORRECTIONFACTOR means do not change the correction factor. TVRESETCORRECTIONFACTOR means reset the correction factor to 1.0. TVCOMPUTECORRECTIONFACTOR means compute the software correction factor for the system time-of-day clock. Refer to date(1) for more details. Time returned is expressed relative in seconds and microseconds since midnight January 1, 1970. The structures pointed to by tp and tzp are defined in <sys/time.h> as: struct timeval { long tv_sec; /* seconds since Jan. 1, 1970 */ long tv_usec; /* and microseconds */ }; struct timezone { Printed 5/12/88 1
GETTIMEOFDAY(2) COMMAND REFERENCE GETTIMEOFDAY(2) int tz_minuteswest; /* of Greenwich */ int tz_dsttime; /* type of dst correction to apply */ }; The timezone structure indicates the local time zone (measured in minutes of time westward from Greenwich), and a flag tz_dsttime, that, if nonzero, indicates that Daylight Saving time applies locally during the appropriate part of the year. Only the super-user can set the time of day. DIAGNOSTICS If Gettimeofday, settimeofday, and cfsettimeofday fail, they can set the following errors in errno: [EFAULT] An argument address references invalid memory. In addition, settimeofday and cfsettimeofday can set the following errors: [EPERM] The caller is not the super-user. [EINVAL] Cflag is set to an invalid value. RETURN VALUE Upon successful completion, a value of 0 is returned. Otherwise, a value of -1 is returned and errno is set to indicate the error. CAVEATS Time is never correct enough to believe the microsecond values. There should be a mechanism by which, at least, local clusters of systems might synchronize their clocks to millisecond granularity. If tp is NULL, the time system time will not be returned or set. If tzp is NULL, the time zone information will not be returned or set. SEE ALSO date(1) and ctime(3c). Printed 5/12/88 2
%%index%% na:432,123; sy:555,2433; de:2988,2518;6010,499; di:6509,1151; rv:7660,280; ca:7940,460; se:8400,141; %%index%%000000000134