Mercurial > emacs
comparison src/systime.h @ 1112:1dba066c1e0a
*** empty log message ***
author | Jim Blandy <jimb@redhat.com> |
---|---|
date | Sun, 13 Sep 1992 10:54:38 +0000 |
parents | d8d503897aa5 |
children | 2a2dabcf877b |
comparison
equal
deleted
inserted
replaced
1111:95f094fdd81e | 1112:1dba066c1e0a |
---|---|
14 GNU General Public License for more details. | 14 GNU General Public License for more details. |
15 | 15 |
16 You should have received a copy of the GNU General Public License | 16 You should have received a copy of the GNU General Public License |
17 along with GNU Emacs; see the file COPYING. If not, write to | 17 along with GNU Emacs; see the file COPYING. If not, write to |
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ | 18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ |
19 | |
20 #ifdef NEED_TIME_H | |
21 | 19 |
22 /* _h_BSDTYPES is checked because on ISC unix, socket.h includes | 20 /* _h_BSDTYPES is checked because on ISC unix, socket.h includes |
23 both time.h and sys/time.h, and the later file is protected | 21 both time.h and sys/time.h, and the later file is protected |
24 from repeated inclusion. We just hope that other systems will | 22 from repeated inclusion. We just hope that other systems will |
25 use this guard either not at all, or similarly. */ | 23 use this guard either not at all, or similarly. */ |
26 #ifndef _h_BSDTYPES | 24 #ifndef _h_BSDTYPES |
27 #include <time.h> | 25 #include <time.h> |
28 #endif /* _h_BSDTYPES */ | 26 #endif /* _h_BSDTYPES */ |
29 #else /* ! defined (NEED_TIME_H) */ | 27 |
30 #ifdef HAVE_TIMEVAL | 28 #ifdef HAVE_TIMEVAL |
29 #ifndef NEED_TIME_H /* Some versions of HP/UX shouldn't have | |
30 this included; time.h should do the trick | |
31 instead. */ | |
31 #include <sys/time.h> | 32 #include <sys/time.h> |
32 #endif /* ! defined (HAVE_TIMEVAL) */ | 33 #endif |
33 #endif /* ! defined (NEED_TIME_H) */ | 34 #endif |
34 | 35 |
35 | 36 |
36 /* EMACS_TIME is the type to use to represent temporal intervals - | 37 /* EMACS_TIME is the type to use to represent temporal intervals - |
37 struct timeval on some systems, int on others. It can be passed as | 38 struct timeval on some systems, int on others. It can be passed as |
38 the timeout argument to the select () system call. | 39 the timeout argument to the select () system call. |
143 /* EMACS_CURRENT_TIME_ZONE (int *OFFSET, int *SAVINGS_FLAG, | 144 /* EMACS_CURRENT_TIME_ZONE (int *OFFSET, int *SAVINGS_FLAG, |
144 char *STANDARD_ABBR, char *SAVINGS_ABBR); | 145 char *STANDARD_ABBR, char *SAVINGS_ABBR); |
145 expands to a statement which stores information about the current | 146 expands to a statement which stores information about the current |
146 time zone in its arguments. | 147 time zone in its arguments. |
147 | 148 |
148 *OFFSET is set to the number of minutes west of Greenwich at which | 149 *OFFSET is set to the number of minutes EAST of Greenwich at which |
149 the site's time zone is located. This should describe the offset | 150 the site's time zone is located. This should describe the offset |
150 to standard time only; if some sort of daylight savings time is in | 151 to standard time only; if some sort of daylight savings time is in |
151 effect, that should not affect this value. Note that the tm_gmtoff | 152 effect, that should not affect this value. Note that the tm_gmtoff |
152 member of the struct tm returned by localtime is adjusted for | 153 member of the struct tm returned by localtime is adjusted for |
153 daylight savings, so you don't want to use localtime to set | 154 daylight savings, so you don't want to use localtime to set |
176 | 177 |
177 #ifndef EMACS_CURRENT_TIME_ZONE | 178 #ifndef EMACS_CURRENT_TIME_ZONE |
178 | 179 |
179 /* If we have timeval, then we have gettimeofday; that's half the battle. */ | 180 /* If we have timeval, then we have gettimeofday; that's half the battle. */ |
180 #ifdef HAVE_TIMEVAL | 181 #ifdef HAVE_TIMEVAL |
181 #define EMACS_GET_TZ_OFFSET_AND_SAVINGS(offset, savings_flag) \ | 182 #define EMACS_GET_TZ_OFFSET(offset) \ |
182 do { \ | 183 do { \ |
183 struct timeval dummy; \ | 184 struct timeval dummy; \ |
184 struct timezone zoneinfo; \ | 185 struct timezone zoneinfo; \ |
185 \ | 186 \ |
186 gettimeofday (&dummy, &zoneinfo); \ | 187 gettimeofday (&dummy, &zoneinfo); \ |
187 *(offset) = zoneinfo.tz_minuteswest; \ | 188 *(offset) = -zoneinfo.tz_minuteswest; \ |
188 *(savings_flag) = zoneinfo.tz_dsttime; \ | |
189 } while (0) | 189 } while (0) |
190 #endif /* ! defined (HAVE_TIMEVAL) */ | 190 #endif /* ! defined (HAVE_TIMEVAL) */ |
191 | 191 |
192 /* System V derivatives have a timezone global variable. */ | |
193 #ifdef USG | |
194 #define EMACS_GET_TZ_OFFSET(offset) \ | |
195 do { \ | |
196 tzset (); \ | |
197 (offset) = timezone; \ | |
198 } | |
199 #endif | |
192 | 200 |
193 /* The following sane systems have a tzname array. The timezone() function | 201 /* The following sane systems have a tzname array. The timezone() function |
194 is a stupid idea; timezone names can only be determined geographically, | 202 is a stupid idea; timezone names can only be determined geographically, |
195 not by Greenwich offset. */ | 203 not by Greenwich offset. */ |
196 #if defined (ultrix) || defined (hpux) || defined (_AIX) | 204 #if defined (ultrix) || defined (hpux) || defined (_AIX) |
220 | 228 |
221 #endif /* ! (defined (hp9000) && ! defined (hpux) && defined (unix)) || defined (MACH) || defined (sun) */ | 229 #endif /* ! (defined (hp9000) && ! defined (hpux) && defined (unix)) || defined (MACH) || defined (sun) */ |
222 #endif /* ! defined (ultrix) || defined (hpux) || defined (_AIX) */ | 230 #endif /* ! defined (ultrix) || defined (hpux) || defined (_AIX) */ |
223 | 231 |
224 /* If we can get all the information we need, let's define the macro! */ | 232 /* If we can get all the information we need, let's define the macro! */ |
225 #if defined (EMACS_GET_TZ_OFFSET_AND_SAVINGS) && defined (EMACS_GET_TZ_NAMES) | 233 #if defined (EMACS_GET_TZ_OFFSET) && defined (EMACS_GET_TZ_NAMES) |
226 | 234 |
227 #define EMACS_CURRENT_TIME_ZONE(offset, savings_flag, standard, savings)\ | 235 #define EMACS_CURRENT_TIME_ZONE(offset, savings_flag, standard, savings)\ |
228 do { \ | 236 do { \ |
229 EMACS_GET_TZ_OFFSET_AND_SAVINGS (offset, savings_flag); \ | 237 EMACS_TIME t; \ |
238 long secs; \ | |
239 struct tm *tmp; \ | |
240 \ | |
241 EMACS_GET_TIME (t); \ | |
242 secs = EMACS_SECS (t); \ | |
243 tmp = localtime (&secs); \ | |
244 *(savings_flag) = tmp->tm_isdst; \ | |
245 \ | |
246 EMACS_GET_TZ_OFFSET (offset); \ | |
230 EMACS_GET_TZ_NAMES (standard, savings); \ | 247 EMACS_GET_TZ_NAMES (standard, savings); \ |
231 } while (0) | 248 } while (0) |
232 | 249 #endif /* ! defined (EMACS_GET_TZ_OFFSET) && defined (EMACS_GET_TZ_NAMES) */ |
233 #endif /* ! defined (EMACS_GET_TZ_OFFSET_AND_SAVINGS) && defined (EMACS_GET_TZ_NAMES) */ | |
234 | 250 |
235 #endif /* EMACS_CURRENT_TIME_ZONE */ | 251 #endif /* EMACS_CURRENT_TIME_ZONE */ |