From 4bc6ed56aa48784c8caf56c3a6fb1a3c972d221c Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Fri, 7 Jan 2011 20:35:43 -0600 Subject: 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 --- lib/libalpm/be_local.c | 25 ++----------------------- 1 file changed, 2 insertions(+), 23 deletions(-) (limited to 'lib/libalpm/be_local.c') diff --git a/lib/libalpm/be_local.c b/lib/libalpm/be_local.c index 4c8e0e9c..109edf49 100644 --- a/lib/libalpm/be_local.c +++ b/lib/libalpm/be_local.c @@ -28,7 +28,6 @@ #include /* intmax_t */ #include #include -#include #include #include /* PATH_MAX */ #include /* setlocale */ @@ -570,33 +569,13 @@ int _alpm_local_db_read(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq) goto error; } _alpm_strtrim(line); - - char first = tolower((unsigned char)line[0]); - if(first > 'a' && first < 'z') { - struct tm tmp_tm = {0}; /* initialize to null in case of failure */ - setlocale(LC_TIME, "C"); - strptime(line, "%a %b %e %H:%M:%S %Y", &tmp_tm); - info->builddate = mktime(&tmp_tm); - setlocale(LC_TIME, ""); - } else { - info->builddate = atol(line); - } + info->builddate = _alpm_parsedate(line); } else if(strcmp(line, "%INSTALLDATE%") == 0) { if(fgets(line, sizeof(line), fp) == NULL) { goto error; } _alpm_strtrim(line); - - char first = tolower((unsigned char)line[0]); - if(first > 'a' && first < 'z') { - struct tm tmp_tm = {0}; /* initialize to null in case of failure */ - setlocale(LC_TIME, "C"); - strptime(line, "%a %b %e %H:%M:%S %Y", &tmp_tm); - info->installdate = mktime(&tmp_tm); - setlocale(LC_TIME, ""); - } else { - info->installdate = atol(line); - } + info->installdate = _alpm_parsedate(line); } else if(strcmp(line, "%PACKAGER%") == 0) { if(fgets(line, sizeof(line), fp) == NULL) { goto error; -- cgit v1.2.3-24-g4f1b