Improved English
[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.\"
0b11b1b3 5.\" @(#)gettimeofday.2 6.4 (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
a2364113 27.I Gettimeofday
0b11b1b3 28returns the system's notion of the current Greenwich time and
a2364113
KM
29the current time zone. Time returned is expressed relative
30in seconds and microseconds since midnight January 1, 1970.
03365d4a 31.PP
a2364113
KM
32The structures pointed to by
33.I tp
34and
35.I tzp
36are defined in
37.I <sys/time.h>
38as:
39.PP
40.nf
41.RS
42.DT
43struct timeval {
0b11b1b3 44 u_long tv_sec; /* seconds since Jan. 1, 1970 */
a2364113
KM
45 long tv_usec; /* and microseconds */
46};
47.sp 1
48struct timezone {
49 int tz_minuteswest; /* of Greenwich */
50 int tz_dsttime; /* type of dst correction to apply */
51};
52.RE
53.fi
54.PP
55The
56.I timezone
57structure indicates the local time zone
58(measured in minutes of time westward from Greenwich),
59and a flag that, if nonzero, indicates that
60Daylight Saving time applies locally during
61the appropriate part of the year.
62.PP
0b11b1b3 63Only the super-user may set the time of day.
a2364113
KM
64.SH RETURN
65A 0 return value indicates that the call succeeded.
66A \-1 return value indicates an error occurred, and in this
67case an error code is stored into the global variable \fIerrno\fP.
68.SH "ERRORS
69The following error codes may be set in \fIerrno\fP:
70.TP 15
71[EFAULT]
72An argument address referenced invalid memory.
73.TP 15
74[EPERM]
75A user other than the super-user attempted to set the time.
76.SH "SEE ALSO"
0b11b1b3 77date(1), ctime(3)
a2364113
KM
78.SH BUGS
79Time is never correct enough to believe the microsecond
0b11b1b3 80values.