Mercurial > emacs
comparison src/mktime.c @ 29737:7568310ea7d6
Unprotoized.
author | Dave Love <fx@gnu.org> |
---|---|
date | Mon, 19 Jun 2000 13:05:51 +0000 |
parents | b7aa6ac26872 |
children | bd73ed6af906 d7ddb3e565de |
comparison
equal
deleted
inserted
replaced
29736:ae52a6b75457 | 29737:7568310ea7d6 |
---|---|
115 #else | 115 #else |
116 /* If we're a mktime substitute in a GNU program, then prefer | 116 /* If we're a mktime substitute in a GNU program, then prefer |
117 localtime to localtime_r, since many localtime_r implementations | 117 localtime to localtime_r, since many localtime_r implementations |
118 are buggy. */ | 118 are buggy. */ |
119 static struct tm * | 119 static struct tm * |
120 my_mktime_localtime_r (const time_t *t, struct tm *tp) | 120 my_mktime_localtime_r (t, tp) |
121 const time_t *t; | |
122 struct tm *tp; | |
121 { | 123 { |
122 struct tm *l = localtime (t); | 124 struct tm *l = localtime (t); |
123 if (! l) | 125 if (! l) |
124 return 0; | 126 return 0; |
125 *tp = *l; | 127 *tp = *l; |
133 YEAR uses the same numbering as TM->tm_year. | 135 YEAR uses the same numbering as TM->tm_year. |
134 All values are in range, except possibly YEAR. | 136 All values are in range, except possibly YEAR. |
135 If TP is null, return a nonzero value. | 137 If TP is null, return a nonzero value. |
136 If overflow occurs, yield the low order bits of the correct answer. */ | 138 If overflow occurs, yield the low order bits of the correct answer. */ |
137 static time_t | 139 static time_t |
138 ydhms_tm_diff (int year, int yday, int hour, int min, int sec, | 140 ydhms_tm_diff (year, yday, hour, min, sec, tp) |
139 const struct tm *tp) | 141 int year, yday, hour, min, sec; |
142 const struct tm *tp; | |
140 { | 143 { |
141 if (!tp) | 144 if (!tp) |
142 return 1; | 145 return 1; |
143 else | 146 else |
144 { | 147 { |
165 | 168 |
166 /* Use CONVERT to convert *T to a broken down time in *TP. | 169 /* Use CONVERT to convert *T to a broken down time in *TP. |
167 If *T is out of range for conversion, adjust it so that | 170 If *T is out of range for conversion, adjust it so that |
168 it is the nearest in-range value and then convert that. */ | 171 it is the nearest in-range value and then convert that. */ |
169 static struct tm * | 172 static struct tm * |
170 ranged_convert (struct tm *(*convert) (const time_t *, struct tm *), | 173 ranged_convert (convert, t, tp) |
171 time_t *t, struct tm *tp) | 174 #ifdef PROTOTYPES |
175 struct tm *(*convert) (const time_t *, struct tm *); | |
176 #else | |
177 struct tm *(*convert)(); | |
178 #endif | |
179 time_t *t; | |
180 struct tm *tp; | |
172 { | 181 { |
173 struct tm *r; | 182 struct tm *r; |
174 | 183 |
175 if (! (r = (*convert) (t, tp)) && *t) | 184 if (! (r = (*convert) (t, tp)) && *t) |
176 { | 185 { |
213 the monotonic and mostly-unit-linear conversion function CONVERT. | 222 the monotonic and mostly-unit-linear conversion function CONVERT. |
214 Use *OFFSET to keep track of a guess at the offset of the result, | 223 Use *OFFSET to keep track of a guess at the offset of the result, |
215 compared to what the result would be for UTC without leap seconds. | 224 compared to what the result would be for UTC without leap seconds. |
216 If *OFFSET's guess is correct, only one CONVERT call is needed. */ | 225 If *OFFSET's guess is correct, only one CONVERT call is needed. */ |
217 time_t | 226 time_t |
218 __mktime_internal (struct tm *tp, | 227 __mktime_internal (tp, convert, offset) |
219 struct tm *(*convert) (const time_t *, struct tm *), | 228 struct tm *tp; |
220 time_t *offset) | 229 #ifdef PROTOTYPES |
230 struct tm *(*convert) (const time_t *, struct tm *); | |
231 #else | |
232 struct tm *(*convert)(); | |
233 #endif | |
234 time_t *offset; | |
221 { | 235 { |
222 time_t t, dt, t0, t1, t2; | 236 time_t t, dt, t0, t1, t2; |
223 struct tm tm; | 237 struct tm tm; |
224 | 238 |
225 /* The maximum number of probes (calls to CONVERT) should be enough | 239 /* The maximum number of probes (calls to CONVERT) should be enough |