bug report 4.2BSD/lib/63
[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.\"
3fa31615 5.\" @(#)gettimeofday.2 6.7 (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
db2c4838
JL
27The system's notion of the current Greenwich time and
28the current time zone
29is obtained with the
30.I gettimeofday
31call, and set with the
32.I settimeofday
33call.
34The time is expressed
35in seconds and microseconds since midnight (0 hour), January 1, 1970.
3fa31615
MK
36The resolution of the system clock is hardware dependent,
37and the time may be updated continuously or in ``ticks.''
fd690c8b
KM
38If
39.I tzp
db2c4838 40is zero, the time zone information will not be returned or set.
03365d4a 41.PP
a2364113
KM
42The structures pointed to by
43.I tp
44and
45.I tzp
46are defined in
47.I <sys/time.h>
48as:
49.PP
50.nf
51.RS
52.DT
53struct timeval {
db2c4838 54 long tv_sec; /* seconds since Jan. 1, 1970 */
a2364113
KM
55 long tv_usec; /* and microseconds */
56};
57.sp 1
58struct timezone {
59 int tz_minuteswest; /* of Greenwich */
60 int tz_dsttime; /* type of dst correction to apply */
61};
62.RE
63.fi
64.PP
65The
66.I timezone
67structure indicates the local time zone
68(measured in minutes of time westward from Greenwich),
69and a flag that, if nonzero, indicates that
70Daylight Saving time applies locally during
71the appropriate part of the year.
72.PP
db2c4838 73Only the super-user may set the time of day or time zone.
a2364113
KM
74.SH RETURN
75A 0 return value indicates that the call succeeded.
76A \-1 return value indicates an error occurred, and in this
77case an error code is stored into the global variable \fIerrno\fP.
78.SH "ERRORS
79The following error codes may be set in \fIerrno\fP:
80.TP 15
81[EFAULT]
82An argument address referenced invalid memory.
83.TP 15
84[EPERM]
85A user other than the super-user attempted to set the time.
86.SH "SEE ALSO"
db2c4838 87date(1), adjtime(2), ctime(3), timed(8)