[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] Add functions to format and parse RFC1123-style times, for ...
- To: or-cvs@freehaven.net
- Subject: [or-cvs] Add functions to format and parse RFC1123-style times, for ...
- From: nickm@seul.org (Nick Mathewson)
- Date: Tue, 3 Aug 2004 21:11:17 -0400 (EDT)
- Delivered-to: archiver@seul.org
- Delivered-to: or-cvs-outgoing@seul.org
- Delivered-to: or-cvs@seul.org
- Delivery-date: Tue, 03 Aug 2004 21:11:28 -0400
- Reply-to: or-dev@freehaven.net
- Sender: owner-or-cvs@freehaven.net
Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/tmp/cvs-serv425/src/or
Modified Files:
test.c
Log Message:
Add functions to format and parse RFC1123-style times, for HTTP protocol.
Index: test.c
===================================================================
RCS file: /home/or/cvsroot/src/or/test.c,v
retrieving revision 1.105
retrieving revision 1.106
diff -u -d -r1.105 -r1.106
--- test.c 22 Jul 2004 22:15:36 -0000 1.105
+++ test.c 4 Aug 2004 01:11:15 -0000 1.106
@@ -439,6 +439,9 @@
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 @@
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();