HP-UX Reference (11i v2 03/08) - 2 System Calls (vol 5)
s
settimeofday(2) settimeofday(2)
NAME
settimeofday - set the date and time
SYNOPSIS
#include <sys/time.h>
int settimeofday struct timeval *tp, const struct timezone *tzp);
DESCRIPTION
The settimeofday()
function sets the current time, expressed as seconds and microseconds since
Epoch, and passed as the
timeval structure pointed to by tp .
The resolution of the system clock is one microsecond.
Security Restrictions
Only a user with appropriate privileges can set the time of day.
PARAMETERS
tp A pointer to a
timeval structure in which the current time is returned.
The
timeval structure includes the following members:
time_t tv_sec /* Seconds. */
long tv_usec /* Microseconds. */
tzp If this parameter is not a null pointer, it is interpreted as a pointer to a
timezone structure under
HP-UX. The
timezone structure has the following fields:
tz_minuteswest The number of minutes that the local time zone is west of Coordinated Universal
Time (UTC) or Epoch.
tz_dsttime A flag that, if nonzero, indicates that Daylight Savings Time (DST) applies locally
during the appropriate part of the year.
RETURN VALUE
gettimeofday() returns the following values under HP-UX:
0 Successful completion.
-1 Failure. errno is set to indicate the error.
ERRORS
If
gettimeofday() fails, errno
is set to the following value under HP-UX:
[EFAULT] An argument address referenced invalid memory.
[EINVAL] The
tv_sec member of the tp parameter to settimeofday()
was less than zero
or greater than 2ˆ31.
[EPERM] A user lacking appropriate privileges attempted to set the time.
WARNINGS
Relying on a granularity of one microsecond may result in code that is not portable to other platforms.
AUTHOR
settimeofday() was developed by the University of California, Berkeley, and HP.
SEE ALSO
date(1), ftime(2), gettimeofday(2), stime(2), time(2), ctime(3C).
HP-UX 11i Version 2: August 2003 − 1 − Hewlett-Packard Company Section 2−−345