rwlogo
SourcePro C++ 12.0

SourcePro® C++ API Reference Guide



   SourcePro C++
Documentation Home

RWHttpDate Class Reference
[HTTP]

Helper class to convert an RWDateTime instance to a date from a string and vice versa, conforming to the HTTP/1.1 specification. More...

#include <rw/http/RWHttpDate.h>

List of all members.

Public Member Functions

 RWHttpDate (void)
 RWHttpDate (const RWDateTime &dt)
 RWHttpDate (const RWCString &str)
RWCString asString () const
RWDateTime getDate () const
void setDate (const RWCString &str)
void setDate (const RWDateTime &dt)
bool isValid () const

Related Functions

(Note that these are not member functions.)



bool operator== (const RWHttpDate &date1, const RWHttpDate &date2)
bool operator!= (const RWHttpDate &date1, const RWHttpDate &date2)
bool operator< (const RWHttpDate &date1, const RWHttpDate &date2)
bool operator<= (const RWHttpDate &date1, const RWHttpDate &date2)
bool operator> (const RWHttpDate &date1, const RWHttpDate &date2)
bool operator>= (const RWHttpDate &date1, const RWHttpDate &date2)
std::ostream & operator<< (std::ostream &s, const RWHttpDate &d)
std::istream & operator>> (std::istream &s, RWHttpDate &d)

Detailed Description

RWHttpDate maintains the date and time. It outputs the date as a string that conforms to the HTTP/1.1 date specification.


Constructor & Destructor Documentation

RWHttpDate::RWHttpDate ( void   )  [inline]

Constructs a default RWHttpDate object. Internal date and time are initialized to the current date and time, respectively.

RWHttpDate::RWHttpDate ( const RWDateTime dt  )  [inline]

Constructs an RWHttpDate object with the internal date and time set to those in dt.

RWHttpDate::RWHttpDate ( const RWCString str  )  [inline]

Constructs an RWHttpDate object with the input str. The str argument must be an HTTP/1.1-compliant date string. The str is parsed for date and time, and the internals are set to the result. If str cannot be parsed, an invalid date is constructed.

HTTP/1.1 defines the following formats as acceptable date strings:

  • 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
Note:
RWHttpDate assumes a two-digit RFC 850 date that appears to be more than 50 years in the future is in fact in the past. (This helps solve the "year 2000" problem.)

Member Function Documentation

RWCString RWHttpDate::asString (  )  const

Returns the internal date and time formatted to comply with the HTTP/1.1 specification. The RWCString should contain 7-bit US-ASCII data. Throws RWInternalErr if isValid() is false.

RWDateTime RWHttpDate::getDate (  )  const [inline]

Returns an RWDateTime constructed on the date associated with the RWHttpDate object.

bool RWHttpDate::isValid ( void   )  const [inline]

Returns true if the internal RWDateTime is not a sentinel value.

void RWHttpDate::setDate ( const RWDateTime dt  )  [inline]

Sets the internal date of the RWHttpDate object to the date and time in dt.

void RWHttpDate::setDate ( const RWCString str  ) 

Sets the internal date of the RWHttpDate object from the string str. The str argument must be an HTTP/1.1-compliant date string. The str is parsed for date and time, and the internals are set to the result. If str cannot be parsed, an invalid date is constructed. The RWCString should contain 7-bit US-ASCII data.


Friends And Related Function Documentation

bool operator!= ( const RWHttpDate date1,
const RWHttpDate date2 
) [related]

Comparison operators.

bool operator< ( const RWHttpDate date1,
const RWHttpDate date2 
) [related]

Comparison operators.

std::ostream & operator<< ( std::ostream &  s,
const RWHttpDate d 
) [related]

Outputs an RWHttpDate object to an std::ostream.

bool operator<= ( const RWHttpDate date1,
const RWHttpDate date2 
) [related]

Comparison operators.

bool operator== ( const RWHttpDate date1,
const RWHttpDate date2 
) [related]

Comparison operators.

bool operator> ( const RWHttpDate date1,
const RWHttpDate date2 
) [related]

Comparison operators.

bool operator>= ( const RWHttpDate date1,
const RWHttpDate date2 
) [related]

Comparison operators.

std::istream & operator>> ( std::istream &  s,
RWHttpDate d 
) [related]

Restores an RWHttpDate from an std::istream into d, replacing the previous contents of d.

 All Classes Functions Variables Typedefs Enumerations Enumerator Friends

© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.