aboutsummaryrefslogtreecommitdiff
path: root/src/or
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2004-08-04 01:11:15 +0000
committerNick Mathewson <nickm@torproject.org>2004-08-04 01:11:15 +0000
commit14d5478f2995e6d9e654acbeb4f36e9a57cc9194 (patch)
treecdb41d5d5ce1e687410bf887effd8a6b90bf8c55 /src/or
parent8b55f73bbee6b282a451e87820cd8f38f13046ac (diff)
downloadtor-14d5478f2995e6d9e654acbeb4f36e9a57cc9194.tar
tor-14d5478f2995e6d9e654acbeb4f36e9a57cc9194.tar.gz
Add functions to format and parse RFC1123-style times, for HTTP protocol.
svn:r2129
Diffstat (limited to 'src/or')
-rw-r--r--src/or/test.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/or/test.c b/src/or/test.c
index f76e66d2d..dd3951370 100644
--- a/src/or/test.c
+++ b/src/or/test.c
@@ -439,6 +439,9 @@ test_util() {
struct timeval start, end;
struct tm a_time;
smartlist_t *sl;
+ char timestr[RFC1123_TIME_LEN+1];
+ time_t t_res;
+ int i;
start.tv_sec = 5;
start.tv_usec = 5000;
@@ -479,6 +482,15 @@ test_util() {
a_time.tm_mday = 10;
test_eq((time_t) 1076393695UL, tor_timegm(&a_time));
+ tor_format_rfc1123_time(timestr, 0);
+ test_streq("Thu, 01 Jan 1970 00:00:00 GMT", timestr);
+ tor_format_rfc1123_time(timestr, (time_t)1091580502UL);
+ test_streq("Wed, 04 Aug 2004 00:48:22 GMT", timestr);
+
+ t_res = 0;
+ i = tor_parse_rfc1123_time(timestr, &t_res);
+ test_eq(i,0);
+ test_eq(t_res, (time_t)1091580502UL);
/* Test smartlist */
sl = smartlist_create();