apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Geoff Greer <angrypars...@mipsisrisc.com>
Subject [Patch] RFC 822 date parsing
Date Wed, 27 Aug 2008 02:23:48 GMT
Hey, it's the overzealous newb again. APR doesn't have any function  
for parsing an RFC 822 date. Since these dates show up in e-mail and  
http headers, I've attached a patch to trunk that adds  
apr_parse_rfc822_date. I've also added it to test_rfcstr, but the test  
is just for one date. I'm guessing this needs to be added to time/ 
win32/timestr.c as well, but I don't have a Windows box for testing.

If you're wondering why the time zone parsing in  
apr_parse_rfc822_time_zone is so crazy, take a look at section 5.1 of  
the spec (http://www.faqs.org/rfcs/rfc822.html). The UTC offset can be  
of the following forms:

1. +/-HHMM
2. A single letter corresponding to an offset (A = UTC-1, B = UTC-2,  
but J is skipped so I is UTC-9 and K is UTC-10). Letter order is  
reversed for positive UTC offsets (N is UTC+1, O is UTC+2). Also Z is  
3. A popular abbreviation (GMT and UT are both UTC. MST and PDT are  

Anyways, it works, but it's not written very well. There are too many  
hard-coded constants hanging around. Validation is pretty weak as  
well. Nonexistent dates (Wed, 17 Aug 2008) can be parsed without  
returning APR_EBADDATE.

It's a start, though. Suggestions or comments would be nice.


View raw message