Penguin
Blame: settimeofday(2)
EditPageHistoryDiffInfoLikePages
Annotated edit history of settimeofday(2) version 1, including all changes. View license author blame.
Rev Author # Line
1 perry 1 GETTIMEOFDAY
2 !!!GETTIMEOFDAY
3 NAME
4 SYNOPSIS
5 DESCRIPTION
6 RETURN VALUE
7 ERRORS
8 NOTE
9 CONFORMING TO
10 SEE ALSO
11 ----
12 !!NAME
13
14
15 gettimeofday, settimeofday - get / set time
16 !!SYNOPSIS
17
18
19 __#include __
20
21
22 __int gettimeofday(struct timeval *__''tv''__, struct
23 timezone *__''tz''__);
24 int settimeofday(const struct timeval *__''tv'' __,
25 const struct timezone *__''tz''__);__
26 !!DESCRIPTION
27
28
29 __gettimeofday__ and __settimeofday__ can get and set
30 the time as well as a timezone. ''tv'' is a
31 __timeval__ struct, as specified in
32 /usr/include/sys/time.h:
33
34
35 struct timeval {
36 long tv_sec; /* seconds */
37 long tv_usec; /* microseconds */
38 };
39 The ''tv_sec'' member of the struct is the number of seconds since the Epoch (see time(2)), and ''tv_usec'' is the amount of microseconds past the current ''tv_sec'' value.
40
41
42 The ''tz'' argument is a __timezone__ :
43
44
45 struct timezone {
46 int tz_minuteswest; /* minutes W of Greenwich */
47 int tz_dsttime; /* type of dst correction */
48 };
49 The use of the timezone struct is obsolete; the ''tz_dsttime'' field has never been used under Linux - it has not been and will not be supported by libc or glibc. Each and every occurrence of this field in the kernel source (other than the declaration) is a bug. Thus, the following is purely of historic interest.
50
51
52 The field ''tz_dsttime'' contains a symbolic constant
53 (values are given below) that indicates in which part of the
54 year Daylight Saving Time is in force. (Note: its value is
55 constant throughout the year - it does not indicate that DST
56 is in force, it just selects an algorithm.) The daylight
57 saving time algorithms defined are as follows :
58
59
60 __DST_NONE__ /* not on dst */__
61 DST_USA__ /* USA style dst */__
62 DST_AUST__ /* Australian style dst */__
63 DST_WET__ /* Western European dst */__
64 DST_MET__ /* Middle European dst */__
65 DST_EET__ /* Eastern European dst */__
66 DST_CAN__ /* Canada */__
67 DST_GB__ /* Great Britain and Eire */__
68 DST_RUM__ /* Rumania */__
69 DST_TUR__ /* Turkey */__
70 DST_AUSTALT__ /* Australian style with shift in 1986
71 */
72
73
74 Of course it turned out that the period in which Daylight
75 Saving Time is in force cannot be given by a simple
76 algorithm, one per country; indeed, this period is
77 determined by unpredictable political decisions. So this
78 method of representing time zones has been abandoned. Under
79 Linux, in a call to __settimeofday__ the
80 ''tz_dsttime'' field should be zero.
81
82
83 Under Linux there is some peculiar `warp clock' semantics
84 associated to the __settimeofday__ system call if on the
85 very first call (after booting) that has a non-NULL
86 ''tz'' argument, the ''tv'' argument is NULL and the
87 ''tz_minuteswest'' field is nonzero. In such a case it is
88 assumed that the CMOS clock is on local time, and that it
89 has to be incremented by this amount to get UTC system time.
90 No doubt it is a bad idea to use this feature.
91
92
93 The following macros are defined to operate on a struct
94 timeval :
95
96
97 #define timerisset(tvp)\
98 ((tvp)-
99 If either ''tv'' or ''tz'' is null, the corresponding structure is not set or returned.
100
101
102 Only the super user may use
103 __settimeofday__.
104 !!RETURN VALUE
105
106
107 __gettimeofday__ and __settimeofday__ return 0 for
108 success, or -1 for failure (in which case ''errno'' is
109 set appropriately).
110 !!ERRORS
111
112
113 __EPERM__
114
115
116 __settimeofday__ is called by someone other than the
117 superuser.
118
119
120 __EINVAL__
121
122
123 Timezone (or something else) is invalid.
124
125
126 __EFAULT__
127
128
129 One of ''tv'' or ''tz'' pointed outside your
130 accessible address space.
131 !!NOTE
132
133
134 The prototype for __settimeofday__ and the defines for
135 __timercmp__, __timerisset__, __timerclear__,
136 __timeradd__, __timersub__ are (since glibc2.2.2) only
137 available if ___BSD_SOURCE__ is defined (either
138 explicitly, or implicitly, by not defining _POSIX_SOURCE or
139 compiling with the -ansi flag).
140 !!CONFORMING TO
141
142
143 SVr4, BSD 4.3
144 !!SEE ALSO
145
146
147 date(1), adjtimex(2), time(2),
148 ctime(3), ftime(3)
149 ----
This page is a man page (or other imported legacy content). We are unable to automatically determine the license status of this page.