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