- updateinfo: cleanup issue date conversion code a bit
authorMichael Schroeder <mls@suse.de>
Wed, 24 Nov 2010 11:34:24 +0000 (12:34 +0100)
committerMichael Schroeder <mls@suse.de>
Wed, 24 Nov 2010 11:34:24 +0000 (12:34 +0100)
ext/repo_updateinfoxml.c

index 406198d..8ad8917 100644 (file)
@@ -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;