diff options
author | Daniel Stenberg <daniel@haxx.se> | 2004-09-11 19:16:34 +0000 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2004-09-11 19:16:34 +0000 |
commit | ade8e47a8c4092c47081c2f9c6adbd968ee87dc7 (patch) | |
tree | f92ecd6cad24ab752b456c9553b64f8336bd2889 /lib/parsedate.c | |
parent | ca52c963c7f9c6df235c5ec02490f0198a8f18e8 (diff) | |
download | curl-ade8e47a8c4092c47081c2f9c6adbd968ee87dc7.tar.gz |
more docs and fixed the delta compared to GMT that prevented test case 141 to
work with this
Diffstat (limited to 'lib/parsedate.c')
-rw-r--r-- | lib/parsedate.c | 36 |
1 files changed, 31 insertions, 5 deletions
diff --git a/lib/parsedate.c b/lib/parsedate.c index 787507f6f..00498a013 100644 --- a/lib/parsedate.c +++ b/lib/parsedate.c @@ -21,6 +21,8 @@ * $Id$ ***************************************************************************/ /* + A brief summary of the date string formats this parser groks: + RFC 2616 3.3.1 Sun, 06 Nov 1994 08:49:37 GMT ; RFC 822, updated by RFC 1123 @@ -33,17 +35,28 @@ 06-Nov-94 08:49:37 GMT Nov 6 08:49:37 1994 - and without the time zone (we always assume GMT): + without the time zone (we always assume GMT): 06 Nov 1994 08:49:37 06-Nov-94 08:49:37 - or even in weird order: + weird order: 1994 Nov 6 08:49:37 (curl_getdate() and GNU date fails) - 08:49:37 06-Nov-94 + GMT 08:49:37 06-Nov-94 Sunday 94 6 Nov 08:49:37 (curl_getdate() and GNU date fails) + time left out: + + 1994 Nov 6 + 06-Nov-94 + Sun Nov 6 94 + + odd separators: + + 1994.Nov.6 + Sun/Nov/6/94/GMT + */ #include "setup.h" #include <stdio.h> @@ -132,6 +145,7 @@ static void skip(const char **date) (*date)++; } +#if 0 #define TM_YEAR_ORIGIN 1900 /* Yield A - B, measured in seconds. (from getdate.y) */ @@ -154,6 +168,7 @@ difftm (struct tm *a, struct tm *b) + (a->tm_min - b->tm_min)) + (a->tm_sec - b->tm_sec)); } +#endif enum assume { DATE_MDAY, @@ -177,7 +192,7 @@ time_t Curl_parsedate(const char *date) int part = 0; /* max 6 parts */ - while(part < 6) { + while(*date && (part < 6)) { bool found=FALSE; skip(&date); @@ -186,7 +201,7 @@ time_t Curl_parsedate(const char *date) /* a name coming up */ char buf[32]=""; size_t len; - sscanf(date, "%31[^ ,\n\t-]", buf); + sscanf(date, "%31[A-Za-z]", buf); len = strlen(buf); if(wdaynum == -1) { @@ -281,6 +296,8 @@ time_t Curl_parsedate(const char *date) { struct tm *gmt; long delta; + time_t t2; + #ifdef HAVE_GMTIME_R /* thread-safe version */ struct tm keeptime2; @@ -288,7 +305,16 @@ time_t Curl_parsedate(const char *date) #else gmt = gmtime(&t); /* use gmtime_r() if available */ #endif +#if 0 + /* previous involved version (that bugs?) */ delta = difftm(&tm, gmt); +#endif + + t2 = mktime(gmt); + delta = t - t2; + + /* if we would like to adjust to a different input time zone than GMT, + we would add that to the delta value right here */ if(t + delta < t) return -1; /* time_t overflow */ |