diff options
author | Dan McGee <dan@archlinux.org> | 2011-01-08 03:35:43 +0100 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2011-01-08 03:55:05 +0100 |
commit | 4bc6ed56aa48784c8caf56c3a6fb1a3c972d221c (patch) | |
tree | 164ca843d1450f9b3534760fb670adc39cfe8e08 /lib/libalpm/be_package.c | |
parent | d288240426551e9d58a708e28fe0217e56d017d6 (diff) | |
download | pacman-4bc6ed56aa48784c8caf56c3a6fb1a3c972d221c.tar.gz pacman-4bc6ed56aa48784c8caf56c3a6fb1a3c972d221c.tar.xz |
Refactor old date parsing into single method
We've managed to duplicate this four times at this point, so make it a
method in util.c instead.
Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'lib/libalpm/be_package.c')
-rw-r--r-- | lib/libalpm/be_package.c | 12 |
1 files changed, 1 insertions, 11 deletions
diff --git a/lib/libalpm/be_package.c b/lib/libalpm/be_package.c index ae9b9533..4ea3eba8 100644 --- a/lib/libalpm/be_package.c +++ b/lib/libalpm/be_package.c @@ -24,7 +24,6 @@ #include <stdlib.h> #include <string.h> #include <limits.h> -#include <ctype.h> #include <locale.h> /* setlocale */ #include <errno.h> @@ -203,16 +202,7 @@ static int parse_descfile(struct archive *a, pmpkg_t *newpkg) } else if(strcmp(key, "license") == 0) { newpkg->licenses = alpm_list_add(newpkg->licenses, strdup(ptr)); } else if(strcmp(key, "builddate") == 0) { - char first = tolower((unsigned char)ptr[0]); - if(first > 'a' && first < 'z') { - struct tm tmp_tm = {0}; /* initialize to null in case of failure */ - setlocale(LC_TIME, "C"); - strptime(ptr, "%a %b %e %H:%M:%S %Y", &tmp_tm); - newpkg->builddate = mktime(&tmp_tm); - setlocale(LC_TIME, ""); - } else { - newpkg->builddate = atol(ptr); - } + newpkg->builddate = _alpm_parsedate(ptr); } else if(strcmp(key, "packager") == 0) { STRDUP(newpkg->packager, ptr, RET_ERR(PM_ERR_MEMORY, -1)); } else if(strcmp(key, "arch") == 0) { |