diff options
author | Michael Schroeder <mls@suse.de> | 2010-11-24 12:34:24 +0100 |
---|---|---|
committer | Michael Schroeder <mls@suse.de> | 2010-11-24 12:34:24 +0100 |
commit | 46af9aee8ed2c9635143c3aeeac95517620f9745 (patch) | |
tree | d77f7d7c8477fcacfd2191d508264ad6c504e49c /ext/repo_updateinfoxml.c | |
parent | 521b28a82e9922b65a85ced7153003ce75de8ca5 (diff) | |
download | libsolv-46af9aee8ed2c9635143c3aeeac95517620f9745.tar.gz libsolv-46af9aee8ed2c9635143c3aeeac95517620f9745.tar.bz2 libsolv-46af9aee8ed2c9635143c3aeeac95517620f9745.zip |
- updateinfo: cleanup issue date conversion code a bit
Diffstat (limited to 'ext/repo_updateinfoxml.c')
-rw-r--r-- | ext/repo_updateinfoxml.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/ext/repo_updateinfoxml.c b/ext/repo_updateinfoxml.c index 406198d..8ad8917 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; |