comparison mcabber/src/utils.c @ 1458:17e95be6c39b

time_t fix from the MirBSD port (Thorsten Glaser)
author Mikael Berthe <mikael@lilotux.net>
date Fri, 11 Apr 2008 21:24:02 +0200
parents 83e275dca409
children d76eff4ed71d
comparison
equal deleted inserted replaced
1457:3a537b4d7f8d 1458:17e95be6c39b
201 int ret; 201 int ret;
202 202
203 tm_time = gmtime(&timestamp); 203 tm_time = gmtime(&timestamp);
204 204
205 ret = snprintf(dststr, 19, "%.4d%02d%02dT%02d:%02d:%02dZ", 205 ret = snprintf(dststr, 19, "%.4d%02d%02dT%02d:%02d:%02dZ",
206 1900+tm_time->tm_year, tm_time->tm_mon+1, tm_time->tm_mday, 206 (int)(1900+tm_time->tm_year), tm_time->tm_mon+1, tm_time->tm_mday,
207 tm_time->tm_hour, tm_time->tm_min, tm_time->tm_sec); 207 tm_time->tm_hour, tm_time->tm_min, tm_time->tm_sec);
208 208
209 return ((ret == -1) ? -1 : 0); 209 return ((ret == -1) ? -1 : 0);
210 } 210 }
211 211
220 time_t retval = 0; 220 time_t retval = 0;
221 char buf[32]; 221 char buf[32];
222 char *c; 222 char *c;
223 int tzoff = 0; 223 int tzoff = 0;
224 int hms_succ = 0; 224 int hms_succ = 0;
225 int tmpyear;
225 226
226 time(&retval); 227 time(&retval);
227 localtime_r(&retval, &t); 228 localtime_r(&retval, &t);
228 229
229 /* Reset time to midnight (00:00:00) */ 230 /* Reset time to midnight (00:00:00) */
231 232
232 snprintf(buf, sizeof(buf), "%s", timestamp); 233 snprintf(buf, sizeof(buf), "%s", timestamp);
233 c = buf; 234 c = buf;
234 235
235 /* 4 digit year */ 236 /* 4 digit year */
236 if (!sscanf(c, "%04d", &t.tm_year)) return 0; 237 if (!sscanf(c, "%04d", &tmpyear)) return 0;
238 t.tm_year = tmpyear;
237 c+=4; 239 c+=4;
238 if (*c == '-') 240 if (*c == '-')
239 c++; 241 c++;
240 242
241 t.tm_year -= 1900; 243 t.tm_year -= 1900;