[FIX] Try to guess current daylight saving time

When backloging we have no clue of a log lines dst, we try to guess it
with current dst, which makes no sense, but at least it provides decent
result when not near dst change.
This commit is contained in:
Arnaud Cornet 2009-01-20 19:30:20 +01:00
parent 500d546706
commit afefc9a3d4
1 changed files with 12 additions and 1 deletions

View File

@ -914,6 +914,13 @@ static time_t compute_time(const char *buf)
{
struct tm tm;
int err;
time_t tv;
/* this is to fill tm_isdst to current tm, expect brokennes when dst
* changes */
time(&tv);
tm = *localtime(&tv);
err = sscanf(buf, "%2d-%2d-%4d %2d:%2d:%2d", &tm.tm_mday, &tm.tm_mon,
&tm.tm_year, &tm.tm_hour, &tm.tm_min, &tm.tm_sec);
if (err != 6)
@ -981,8 +988,12 @@ static int log_backread_file(log_t *log, logstore_t *store, logfile_t *lf,
if (start != 0) {
time_t linetime = compute_time(buf);
/* parse error, don't backlog */
if (linetime == (time_t)-1)
if (linetime == (time_t)-1) {
list_add_last(res, _log_wrap("Error in "
"timestamp in %s",
store->name));
continue;
}
/* too old line, don't backlog */
if (linetime < start)
continue;