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