Try to fix SIGIO problem with Sun machines, h_errno with
[unix-history] / usr / src / lib / libc / sys / gettimeofday.2
CommitLineData
03365d4a
KM
1.\" Copyright (c) 1980 Regents of the University of California.
2.\" All rights reserved. The Berkeley software License Agreement
3.\" specifies the terms and conditions for redistribution.
4.\"
1347a72e 5.\" @(#)gettimeofday.2 6.8 (Berkeley) %G%
03365d4a 6.\"
8c6e89a6 7.TH GETTIMEOFDAY 2 ""
03365d4a
KM
8.UC 4
9.SH NAME
a2364113 10gettimeofday, settimeofday \- get/set date and time
03365d4a
KM
11.SH SYNOPSIS
12.nf
a2364113
KM
13.ft B
14#include <sys/time.h>
15.PP
16.ft B
17gettimeofday(tp, tzp)
18struct timeval *tp;
19struct timezone *tzp;
20.PP
21.ft B
22settimeofday(tp, tzp)
23struct timeval *tp;
24struct timezone *tzp;
03365d4a
KM
25.fi
26.SH DESCRIPTION
1347a72e
KB
27The system's notion of the current Greenwich time and the current time
28zone is obtained with the \fIgettimeofday\fP call, and set with the
29\fIsettimeofday\fP call. The time is expressed in seconds and microseconds
30since midnight (0 hour), January 1, 1970. The resolution of the system
31clock is hardware dependent, and the time may be updated continuously or
32in ``ticks.'' If \fItp\fP or \fItzp\fP is NULL, the associated time
33information will not be returned or set.
03365d4a 34.PP
a2364113
KM
35The structures pointed to by
36.I tp
37and
38.I tzp
39are defined in
40.I <sys/time.h>
41as:
42.PP
43.nf
44.RS
45.DT
46struct timeval {
db2c4838 47 long tv_sec; /* seconds since Jan. 1, 1970 */
a2364113
KM
48 long tv_usec; /* and microseconds */
49};
50.sp 1
51struct timezone {
52 int tz_minuteswest; /* of Greenwich */
53 int tz_dsttime; /* type of dst correction to apply */
54};
55.RE
56.fi
57.PP
58The
59.I timezone
60structure indicates the local time zone
61(measured in minutes of time westward from Greenwich),
62and a flag that, if nonzero, indicates that
63Daylight Saving time applies locally during
64the appropriate part of the year.
65.PP
db2c4838 66Only the super-user may set the time of day or time zone.
a2364113
KM
67.SH RETURN
68A 0 return value indicates that the call succeeded.
69A \-1 return value indicates an error occurred, and in this
70case an error code is stored into the global variable \fIerrno\fP.
71.SH "ERRORS
72The following error codes may be set in \fIerrno\fP:
73.TP 15
74[EFAULT]
75An argument address referenced invalid memory.
76.TP 15
77[EPERM]
78A user other than the super-user attempted to set the time.
79.SH "SEE ALSO"
db2c4838 80date(1), adjtime(2), ctime(3), timed(8)