| skipped 123 lines |
124 | 124 | | * returns the seconds east of UTC given 'g' and its corresponding gmtime() |
125 | 125 | | * representation |
126 | 126 | | */ |
127 | | - | static time_t compute_tz(time_t g, struct tm *utc) |
| 127 | + | static int compute_tz(time_t g, struct tm *utc) |
128 | 128 | | { |
129 | 129 | | struct tm lt = mutt_date_localtime(g); |
130 | 130 | | |
131 | | - | time_t t = (((lt.tm_hour - utc->tm_hour) * 60) + (lt.tm_min - utc->tm_min)) * 60; |
| 131 | + | int tz = (((lt.tm_hour - utc->tm_hour) * 60) + (lt.tm_min - utc->tm_min)) * 60; |
132 | 132 | | |
133 | 133 | | int yday = (lt.tm_yday - utc->tm_yday); |
134 | 134 | | if (yday != 0) |
| skipped 2 lines |
137 | 137 | | if ((yday == -1) || /* UTC passed midnight before localtime */ |
138 | 138 | | (yday > 1)) /* UTC passed new year before localtime */ |
139 | 139 | | { |
140 | | - | t -= (24 * 60 * 60); |
| 140 | + | tz -= (24 * 60 * 60); |
141 | 141 | | } |
142 | 142 | | else |
143 | 143 | | { |
144 | | - | t += (24 * 60 * 60); |
| 144 | + | tz += (24 * 60 * 60); |
145 | 145 | | } |
146 | 146 | | } |
147 | 147 | | |
148 | | - | return t; |
| 148 | + | return tz; |
149 | 149 | | } |
150 | 150 | | |
151 | 151 | | /** |
| skipped 51 lines |
203 | 203 | | * Returns the local timezone in seconds east of UTC for the time t, |
204 | 204 | | * or for the current time if t is zero. |
205 | 205 | | */ |
206 | | - | time_t mutt_date_local_tz(time_t t) |
| 206 | + | int mutt_date_local_tz(time_t t) |
207 | 207 | | { |
208 | 208 | | /* Check we haven't overflowed the time (on 32-bit arches) */ |
209 | 209 | | if ((t == TIME_T_MAX) || (t == TIME_T_MIN)) |
| skipped 42 lines |
252 | 252 | | return TIME_T_MAX; |
253 | 253 | | |
254 | 254 | | /* Compute the number of days since January 1 in the same year */ |
255 | | - | time_t g = AccumDaysPerMonth[t->tm_mon % mutt_array_size(Months)]; |
| 255 | + | int yday = AccumDaysPerMonth[t->tm_mon % mutt_array_size(Months)]; |
256 | 256 | | |
257 | 257 | | /* The leap years are 1972 and every 4. year until 2096, |
258 | 258 | | * but this algorithm will fail after year 2099 */ |
259 | | - | g += t->tm_mday; |
| 259 | + | yday += t->tm_mday; |
260 | 260 | | if ((t->tm_year % 4) || (t->tm_mon < 2)) |
261 | | - | g--; |
262 | | - | t->tm_yday = g; |
| 261 | + | yday--; |
| 262 | + | t->tm_yday = yday; |
| 263 | + | |
| 264 | + | time_t g = yday; |
263 | 265 | | |
264 | 266 | | /* Compute the number of days since January 1, 1970 */ |
265 | 267 | | g += (t->tm_year - 70) * (time_t) 365; |
| skipped 115 lines |
381 | 383 | | return; |
382 | 384 | | |
383 | 385 | | struct tm tm; |
384 | | - | time_t tz = 0; |
| 386 | + | int tz = 0; |
385 | 387 | | |
386 | 388 | | time_t t = mutt_date_epoch(); |
387 | 389 | | if (local) |
| skipped 8 lines |
396 | 398 | | |
397 | 399 | | tz /= 60; |
398 | 400 | | |
399 | | - | mutt_buffer_add_printf(buf, "%s, %d %s %d %02d:%02d:%02d %+03d%02d", |
400 | | - | Weekdays[tm.tm_wday], tm.tm_mday, Months[tm.tm_mon], |
401 | | - | tm.tm_year + 1900, tm.tm_hour, tm.tm_min, tm.tm_sec, |
402 | | - | (int) tz / 60, (int) abs((int) tz) % 60); |
| 401 | + | mutt_buffer_add_printf(buf, "%s, %d %s %d %02d:%02d:%02d %+03d%02d", Weekdays[tm.tm_wday], |
| 402 | + | tm.tm_mday, Months[tm.tm_mon], tm.tm_year + 1900, |
| 403 | + | tm.tm_hour, tm.tm_min, tm.tm_sec, tz / 60, abs(tz) % 60); |
403 | 404 | | } |
404 | 405 | | |
405 | 406 | | /** |
| skipped 154 lines |
560 | 561 | | return -1; |
561 | 562 | | |
562 | 563 | | struct tm tm = mutt_date_localtime(timestamp); |
563 | | - | time_t tz = mutt_date_local_tz(timestamp); |
| 564 | + | int tz = mutt_date_local_tz(timestamp); |
564 | 565 | | |
565 | 566 | | tz /= 60; |
566 | 567 | | |
567 | 568 | | return snprintf(buf, buflen, "%02d-%s-%d %02d:%02d:%02d %+03d%02d", |
568 | 569 | | tm.tm_mday, Months[tm.tm_mon], tm.tm_year + 1900, tm.tm_hour, |
569 | | - | tm.tm_min, tm.tm_sec, (int) tz / 60, (int) abs((int) tz) % 60); |
| 570 | + | tm.tm_min, tm.tm_sec, tz / 60, abs(tz) % 60); |
570 | 571 | | } |
571 | 572 | | |
572 | 573 | | /** |
| skipped 140 lines |