SourcePro® API Reference Guide

 
Loading...
Searching...
No Matches
RWHttpDate Class Reference

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>

Public Member Functions

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

Related Symbols

(Note that these are not member symbols.)

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)
 
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::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() [1/3]

RWHttpDate::RWHttpDate ( void )
inline

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

◆ RWHttpDate() [2/3]

RWHttpDate::RWHttpDate ( const RWDateTime & dt)
inline

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

◆ RWHttpDate() [3/3]

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 06 08:49:37 1994; C++ Standard Library std::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

◆ asString()

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.

◆ getDate()

RWDateTime RWHttpDate::getDate ( ) const
inline

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

◆ isValid()

bool RWHttpDate::isValid ( ) const
inline

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

◆ setDate() [1/2]

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.

◆ setDate() [2/2]

void RWHttpDate::setDate ( const RWDateTime & dt)
inline

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

Friends And Related Symbol Documentation

◆ operator!=()

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

Comparison operators.

◆ operator<()

bool operator< ( const RWHttpDate & date1,
const RWHttpDate & date2 )
related

Comparison operators.

◆ operator<<()

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

Outputs an RWHttpDate object to an std::ostream.

◆ operator<=()

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

Comparison operators.

◆ operator==()

bool operator== ( const RWHttpDate & date1,
const RWHttpDate & date2 )
related

Comparison operators.

◆ operator>()

bool operator> ( const RWHttpDate & date1,
const RWHttpDate & date2 )
related

Comparison operators.

◆ operator>=()

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

Comparison operators.

◆ operator>>()

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

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

Copyright © 2024 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved.