From: Michael Schroeder Date: Wed, 24 Nov 2010 11:34:24 +0000 (+0100) Subject: - updateinfo: cleanup issue date conversion code a bit X-Git-Tag: BASE-SuSE-Code-12_1-Branch~157^2~1 X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=46af9aee8ed2c9635143c3aeeac95517620f9745;p=thirdparty%2Flibsolv.git - updateinfo: cleanup issue date conversion code a bit --- diff --git a/ext/repo_updateinfoxml.c b/ext/repo_updateinfoxml.c index 406198d1..8ad8917d 100644 --- a/ext/repo_updateinfoxml.c +++ b/ext/repo_updateinfoxml.c @@ -127,13 +127,15 @@ struct parsedata { static time_t datestr2timestamp(const char *date) { - if (!date) - return 0; + const char *p; + struct tm tm; - if (strlen(date) == strspn(date, "0123456789")) + if (!date || !*date) + return 0; + for (p = date; *p >= '0' && *p <= '9'; p++) + ; + if (!*p) return atoi(date); - - struct tm tm; memset(&tm, 0, sizeof(tm)); if (!strptime(date, "%F%T", &tm)) return 0; @@ -318,7 +320,9 @@ startElement(void *userData, const char *name, const char **atts) } if (date) { - repodata_set_num(pd->data, pd->datanum, SOLVABLE_BUILDTIME, datestr2timestamp(date)); + time_t t = datestr2timestamp(date); + if (t) + repodata_set_num(pd->data, pd->datanum, SOLVABLE_BUILDTIME, t); } } break;