From 0bc5d2ca4cee4e6ace987d424098d643e40f1ca1 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Sat, 16 Apr 2016 23:27:38 +0100 Subject: create date and time to seconds since epoch processing utility function currently NetSurf uses curl_getdate to convert textural date and time strings into seconds since epoch. It is betetr to move this functionality to a utility function so curl_getdate can easily be replaced if required. --- content/urldb.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'content/urldb.c') diff --git a/content/urldb.c b/content/urldb.c index edb49b549..d7a7fed1c 100644 --- a/content/urldb.c +++ b/content/urldb.c @@ -95,7 +95,6 @@ #include #include #include -#include #include "utils/nsoption.h" #include "utils/log.h" @@ -103,6 +102,7 @@ #include "utils/url.h" #include "utils/utils.h" #include "utils/bloom.h" +#include "utils/time.h" #include "image/bitmap.h" #include "desktop/cookie_manager.h" #include "desktop/gui_internal.h" @@ -1587,22 +1587,21 @@ static bool urldb_parse_avpair(struct cookie_internal_data *c, char *n, } else if (strcasecmp(n, "Expires") == 0) { char *datenoday; time_t expires; + nserror res; - /* Strip dayname from date (these are hugely - * variable and liable to break the parser. - * They also serve no useful purpose) */ + /* Strip dayname from date (these are hugely variable + * and liable to break the parser. They also serve no + * useful purpose) */ for (datenoday = v; *datenoday && !isdigit(*datenoday); datenoday++) ; /* do nothing */ - expires = curl_getdate(datenoday, NULL); - if (expires == -1) { - /* assume we have an unrepresentable - * date => force it to the maximum - * possible value of a 32bit time_t - * (this may break in 2038. We'll - * deal with that once we come to - * it) */ + res = nsc_strntimet(datenoday, strlen(datenoday), &expires); + if (res != NSERROR_OK) { + /* assume we have an unrepresentable date => + * force it to the maximum possible value of a + * 32bit time_t (this may break in 2038. We'll + * deal with that once we come to it) */ expires = (time_t)0x7fffffff; } c->expires = expires; -- cgit v1.2.3