summaryrefslogtreecommitdiffstats
path: root/lib/libalpm/util.c
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-01-08 03:35:43 +0100
committerDan McGee <dan@archlinux.org>2011-01-08 03:55:05 +0100
commit4bc6ed56aa48784c8caf56c3a6fb1a3c972d221c (patch)
tree164ca843d1450f9b3534760fb670adc39cfe8e08 /lib/libalpm/util.c
parentd288240426551e9d58a708e28fe0217e56d017d6 (diff)
downloadpacman-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/util.c')
-rw-r--r--lib/libalpm/util.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c
index 18245646..5f7512fb 100644
--- a/lib/libalpm/util.c
+++ b/lib/libalpm/util.c
@@ -923,4 +923,17 @@ unsigned long _alpm_hash_sdbm(const char *str)
return(hash);
}
+long _alpm_parsedate(const char *line)
+{
+ if(isalpha((unsigned char)line[0])) {
+ /* initialize to null in case of failure */
+ struct tm tmp_tm = { 0 };
+ setlocale(LC_TIME, "C");
+ strptime(line, "%a %b %e %H:%M:%S %Y", &tmp_tm);
+ setlocale(LC_TIME, "");
+ return(mktime(&tmp_tm));
+ }
+ return(atol(line));
+}
+
/* vim: set ts=2 sw=2 noet: */