|
|
1.1 root 1: .\" Copyright (c) 1980 The Regents of the University of California.
2: .\" All rights reserved.
3: .\"
4: .\" Redistribution and use in source and binary forms are permitted provided
5: .\" that: (1) source distributions retain this entire copyright notice and
6: .\" comment, and (2) distributions including binaries display the following
7: .\" acknowledgement: ``This product includes software developed by the
8: .\" University of California, Berkeley and its contributors'' in the
9: .\" documentation or other materials provided with the distribution and in
10: .\" all advertising materials mentioning features or use of this software.
11: .\" Neither the name of the University nor the names of its contributors may
12: .\" be used to endorse or promote products derived from this software without
13: .\" specific prior written permission.
14: .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
15: .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
16: .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
17: .\"
18: .\" @(#)gettimeofday.2 6.10 (Berkeley) 6/23/90
19: .\"
20: .TH GETTIMEOFDAY 2 "June 23, 1990"
21: .UC 4
22: .SH NAME
23: gettimeofday, settimeofday \- get/set date and time
24: .SH SYNOPSIS
25: .nf
26: .ft B
27: #include <sys/time.h>
28: .PP
29: .ft B
30: gettimeofday(tp, tzp)
31: struct timeval *tp;
32: struct timezone *tzp;
33: .PP
34: .ft B
35: settimeofday(tp, tzp)
36: struct timeval *tp;
37: struct timezone *tzp;
38: .fi
39: .SH DESCRIPTION
40: The system's notion of the current Greenwich time and the current time
41: zone is obtained with the \fIgettimeofday\fP call, and set with the
42: \fIsettimeofday\fP call. The time is expressed in seconds and microseconds
43: since midnight (0 hour), January 1, 1970. The resolution of the system
44: clock is hardware dependent, and the time may be updated continuously or
45: in ``ticks.'' If \fItp\fP or \fItzp\fP is NULL, the associated time
46: information will not be returned or set.
47: .PP
48: The structures pointed to by
49: .I tp
50: and
51: .I tzp
52: are defined in
53: .I <sys/time.h>
54: as:
55: .PP
56: .nf
57: .RS
58: .DT
59: struct timeval {
60: long tv_sec; /* seconds since Jan. 1, 1970 */
61: long tv_usec; /* and microseconds */
62: };
63: .sp 1
64: struct timezone {
65: int tz_minuteswest; /* of Greenwich */
66: int tz_dsttime; /* type of dst correction to apply */
67: };
68: .RE
69: .fi
70: .PP
71: The
72: .I timezone
73: structure indicates the local time zone
74: (measured in minutes of time westward from Greenwich),
75: and a flag that, if nonzero, indicates that
76: Daylight Saving time applies locally during
77: the appropriate part of the year.
78: .PP
79: Only the super-user may set the time of day or time zone.
80: .SH RETURN
81: A 0 return value indicates that the call succeeded.
82: A \-1 return value indicates an error occurred, and in this
83: case an error code is stored into the global variable \fIerrno\fP.
84: .SH "ERRORS
85: The following error codes may be set in \fIerrno\fP:
86: .TP 15
87: [EFAULT]
88: An argument address referenced invalid memory.
89: .TP 15
90: [EPERM]
91: A user other than the super-user attempted to set the time.
92: .SH "SEE ALSO"
93: date(1), adjtime(2), ctime(3), timed(8)
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.