Use boost date_time to parse and create HTTP-dates

Posted by John Price on Stack Overflow See other posts from Stack Overflow or by John Price
Published on 2010-05-15T01:22:04Z Indexed on 2010/05/15 1:24 UTC
Read the original article Hit count: 298

Filed under:
|
|
|

I'm writing a kind of HTTP proxy, so I need to be able to do 3 things:

  1. Parse an HTTP-date given any of the 3 formats specified in RFC 2616, sec 3.3,
  2. Convert a file date-time to an HTTP-date string, and
  3. Output the date to a string.

For reference, theses are examples of the date-times I need to parse. I will output only the first format:

  Sun, 06 Nov 1994 08:49:37 GMT  ; RFC 822, updated by RFC 1123
  Sunday, 06-Nov-94 08:49:37 GMT ; RFC 850, obsoleted by RFC 1036
  Sun Nov  6 08:49:37 1994       ; ANSI C's asctime() format

I'm pretty sure Boost date_time can do all of this, but I'm having some trouble with number 1. Does anyone already have code to do this? Perhaps I'm not using google proficiently, but I can't find an example of how to do this with boost anywhere.

Thanks for any help!

© Stack Overflow or respective owner

Related posts about boost

Related posts about boost-date-time