Public Member Functions | Static Public Member Functions

CdcHttpTime Class Reference

This class makes a time and date object. More...

#include <DcHttpTime.h>

List of all members.

Public Member Functions

 CdcHttpTime (bool gmt=false)
 Default constructor - makes CdcHttpTime object, that holds the current time.
 CdcHttpTime (time_t time, bool gmt=false)
 Construct a CdcHttpTime object from "C" time_t.
 CdcHttpTime (int year, int month, int day, int hour, int min, int sec)
 Constructor that builds a CdcHttpTime object from YYYY, MM, DD, HH, MM and SS.
 CdcHttpTime (const CdcString &timestr) throw (CdcException)
 Constructor that gets one of the 3 HTTP formats time string.
CdcHttpTime ToGmt ()
 Create the same object but in GMT time.
CdcHttpTime ToLocal ()
 Create the same object but in local time.
CdcString Format (const CdcString &format_str) const
 Create a string from the date and time.
CdcString FormatGmt (const CdcString &format_str) const
 Create a string from the GMT date and time.
int GetSeconds () const
 Return the seconds of this time object.
int GetMinutes () const
 Return the minutes of this time object.
int GetHours () const
 Return the hours of this time object.
int GetDays () const
 Return the days of this time object.
int GetWeeks () const
 Return the week in the year of this time object (0..50).
int GetMonths () const
 Return the months of this time object.
int GetYears () const
 Return the years of this time object.
CdcHttpTimeAddSeconds (int secs)
 Add seconds to this time object.
CdcHttpTimeAddMinutes (int mins)
 Add minutes to this time object.
CdcHttpTimeAddHours (int hrs)
 Add hours to this time object.
CdcHttpTimeAddDays (int days)
 Add days to this time object.
CdcHttpTimeAddMonths (int months)
 Add months to this time object.
CdcHttpTimeAddYears (int years)
 Add years to this time object.
bool operator== (const CdcHttpTime &time) const
 CdcHttpTime comparisons.
bool operator!= (const CdcHttpTime &time) const
bool operator> (const CdcHttpTime &time) const
bool operator< (const CdcHttpTime &time) const
bool operator>= (const CdcHttpTime &time) const
bool operator<= (const CdcHttpTime &time) const
double operator- (const CdcHttpTime &time) const
 Get the different between two times in seconds.

Static Public Member Functions

static CdcHttpTime GetCurrentTime ()
 Static function to get an object that set to the current time.
static CdcHttpTime GetCurrentTimeGMT ()
 Static function to get an object that set to the GMT current time.
static void Init ()
 Initialize the month name to number, map.

Detailed Description

This class makes a time and date object.

it can handle HTTP time strings, and do some basic time and date operations.

There are three types of HTTP date / time 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

Author:
Erez Bibi
Version:
1.0

Definition at line 45 of file DcHttpTime.h.


Constructor & Destructor Documentation

CdcHttpTime::CdcHttpTime ( bool  gmt = false )

Default constructor - makes CdcHttpTime object, that holds the current time.

Parameters:
gmtIf True, the time will be GMT (UTC) time.

Definition at line 31 of file DcHttpTime.cpp.

CdcHttpTime::CdcHttpTime ( time_t  time,
bool  gmt = false 
)

Construct a CdcHttpTime object from "C" time_t.

Parameters:
timeThe time as an ANSI C time_t value.
gmtIf True, the time will be GMT (UTC) time.

Definition at line 46 of file DcHttpTime.cpp.

CdcHttpTime::CdcHttpTime ( int  year,
int  month,
int  day,
int  hour,
int  min,
int  sec 
)

Constructor that builds a CdcHttpTime object from YYYY, MM, DD, HH, MM and SS.

Definition at line 61 of file DcHttpTime.cpp.

CdcHttpTime::CdcHttpTime ( const CdcString timestr ) throw (CdcException)

Constructor that gets one of the 3 HTTP formats time string.

Parameters:
timestrThe time as string.
Exceptions:
(CdcException)If the string cannot be parsed.

Definition at line 76 of file DcHttpTime.cpp.


Member Function Documentation

CdcHttpTime & CdcHttpTime::AddDays ( int  days )

Add days to this time object.

Definition at line 139 of file DcHttpTime.cpp.

CdcHttpTime & CdcHttpTime::AddHours ( int  hrs )

Add hours to this time object.

Definition at line 132 of file DcHttpTime.cpp.

CdcHttpTime & CdcHttpTime::AddMinutes ( int  mins )

Add minutes to this time object.

Definition at line 125 of file DcHttpTime.cpp.

CdcHttpTime & CdcHttpTime::AddMonths ( int  months )

Add months to this time object.

Definition at line 146 of file DcHttpTime.cpp.

CdcHttpTime & CdcHttpTime::AddSeconds ( int  secs )

Add seconds to this time object.

Definition at line 118 of file DcHttpTime.cpp.

CdcHttpTime & CdcHttpTime::AddYears ( int  years )

Add years to this time object.

Definition at line 153 of file DcHttpTime.cpp.

CdcString CdcHttpTime::Format ( const CdcString format_str ) const

Create a string from the date and time.

see the ANSI C strftime for the format details.

Definition at line 94 of file DcHttpTime.cpp.

CdcString CdcHttpTime::FormatGmt ( const CdcString format_str ) const

Create a string from the GMT date and time.

see the ANSI C strftime\ for the format details.

Definition at line 105 of file DcHttpTime.cpp.

static CdcHttpTime CdcHttpTime::GetCurrentTime (  ) [inline, static]

Static function to get an object that set to the current time.

Definition at line 230 of file DcHttpTime.h.

static CdcHttpTime CdcHttpTime::GetCurrentTimeGMT (  ) [inline, static]

Static function to get an object that set to the GMT current time.

Definition at line 238 of file DcHttpTime.h.

int CdcHttpTime::GetDays (  ) const [inline]

Return the days of this time object.

Definition at line 164 of file DcHttpTime.h.

int CdcHttpTime::GetHours (  ) const [inline]

Return the hours of this time object.

Definition at line 160 of file DcHttpTime.h.

int CdcHttpTime::GetMinutes (  ) const [inline]

Return the minutes of this time object.

Definition at line 156 of file DcHttpTime.h.

int CdcHttpTime::GetMonths (  ) const [inline]

Return the months of this time object.

Definition at line 172 of file DcHttpTime.h.

int CdcHttpTime::GetSeconds (  ) const [inline]

Return the seconds of this time object.

Definition at line 152 of file DcHttpTime.h.

int CdcHttpTime::GetWeeks (  ) const [inline]

Return the week in the year of this time object (0..50).

Definition at line 168 of file DcHttpTime.h.

int CdcHttpTime::GetYears (  ) const [inline]

Return the years of this time object.

Definition at line 176 of file DcHttpTime.h.

void CdcHttpTime::Init (  ) [static]

Initialize the month name to number, map.

Static Function.

Definition at line 257 of file DcHttpTime.cpp.

bool CdcHttpTime::operator!= ( const CdcHttpTime time ) const [inline]

Definition at line 204 of file DcHttpTime.h.

double CdcHttpTime::operator- ( const CdcHttpTime time ) const [inline]

Get the different between two times in seconds.

Definition at line 223 of file DcHttpTime.h.

bool CdcHttpTime::operator< ( const CdcHttpTime time ) const [inline]

Definition at line 210 of file DcHttpTime.h.

bool CdcHttpTime::operator<= ( const CdcHttpTime time ) const [inline]

Definition at line 216 of file DcHttpTime.h.

bool CdcHttpTime::operator== ( const CdcHttpTime time ) const [inline]

CdcHttpTime comparisons.

Definition at line 201 of file DcHttpTime.h.

bool CdcHttpTime::operator> ( const CdcHttpTime time ) const [inline]

Definition at line 207 of file DcHttpTime.h.

bool CdcHttpTime::operator>= ( const CdcHttpTime time ) const [inline]

Definition at line 213 of file DcHttpTime.h.

CdcHttpTime CdcHttpTime::ToGmt (  )

Create the same object but in GMT time.

Definition at line 84 of file DcHttpTime.cpp.

CdcHttpTime CdcHttpTime::ToLocal (  )

Create the same object but in local time.

Definition at line 89 of file DcHttpTime.cpp.


The documentation for this class was generated from the following files: