code::CalendarDate Class Reference

List of all members.

Detailed Description

C++ wrapper for struct tm.

Original version by Lulin Song had a similar interface but did not incorporate the standard C library structure, tm.

This class has only one-second accuracy. If you want arithmetic operations and subsecond accuracy, then use Time and TimeInterval.

Author:
Thomas E. Vaughan, Lulin Song
Version:
Id
code_CalendarDate.h,v 1.33 2009/06/02 20:17:38 lakshman Exp
See also:
Time


Public Member Functions

 CalendarDate (const Time &)
 Convert from Time.
 CalendarDate (const std::string &, int offset=-1)
 Convert from a string.
 CalendarDate (const std::string &, const std::string &)
 Facilitate output from hires algorithms (in UTC).
 CalendarDate (int, unsigned short, unsigned short, unsigned short, unsigned short, unsigned short)
 Make a CalendarDate from a list of integers (wrt UTC).
 ~CalendarDate ()
 Reproduce responsibly.
 operator Time () const
 Autoconversion to Time.
Time getTime () const
 Return a Time.
bool operator== (const CalendarDate &) const
 Equality comparison operator.
bool operator< (const CalendarDate &) const
 Less-than comparison operator.
int getYear () const
 Return the (UTC) year.
int getMonth () const
 Return the (UTC) month (1--12) of the year.
int getDay () const
 Return the (UTC) day (1--31) of the month.
int getHour () const
 Return the (UTC) hour (0--23) of the day.
int getMinute () const
 Return the minute (0--59) of the hour.
int getSecond () const
 Return the second (0--61) of the minute.
std::string getString (bool withSpace=true) const
 Convert a CalendarDate object to a UTC std::string.
std::string getStringForFileName () const
 Convert a CalendarDate object to a UTC std::string that is suitable to use as a file name.
bool isValid (Time *=0) const
 Indicate whether the object represents a valid date.

Static Public Member Functions

static CalendarDate UTC (tm &)
 Convert from tm that refers to UTC.
static CalendarDate LocalTime (tm &)
 Convert from tm that refers to local time.
static CalendarDate fromStringForFileName (const std::string &)
 Understands the filename format used by the getStringForFileName function and converts back to a CalendarDate.


Constructor & Destructor Documentation

code::CalendarDate::CalendarDate ( const Time  ) 

Convert from Time.

code::CalendarDate::CalendarDate ( const std::string &  ,
int  offset = -1 
)

Convert from a string.

Parameters:
string 22 characters formatted as [2001-02/28-16:00:00-UTC] or [2001 02/28 16:00:00 UTC]

code::CalendarDate::CalendarDate ( const std::string &  ,
const std::string &   
)

Facilitate output from hires algorithms (in UTC).

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! We assume a TWO-CHARACTER year. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Parameters:
const_string& eight characters formatted as ' mmddyy'
const_string& eight characters formatted as ' hhmmss'

code::CalendarDate::CalendarDate ( int  ,
unsigned  short,
unsigned  short,
unsigned  short,
unsigned  short,
unsigned  short 
)

Make a CalendarDate from a list of integers (wrt UTC).

Parameters:
int year of "common era"
unsigned_short month (1--12) of the year
unsigned_short day (1--31) of the month
unsigned_short hour (0--23) of the day
unsigned_short minute (0--59) of the hour
unsigned_short second (0--61) of the minute. Values beyond 59 allow for leap seconds.

code::CalendarDate::~CalendarDate (  )  [inline]

Reproduce responsibly.


Member Function Documentation

static CalendarDate code::CalendarDate::fromStringForFileName ( const std::string &   )  [static]

Understands the filename format used by the getStringForFileName function and converts back to a CalendarDate.

The input should look like: 20010228-160316

int code::CalendarDate::getDay (  )  const [inline]

Return the (UTC) day (1--31) of the month.

int code::CalendarDate::getHour (  )  const [inline]

Return the (UTC) hour (0--23) of the day.

int code::CalendarDate::getMinute (  )  const [inline]

Return the minute (0--59) of the hour.

int code::CalendarDate::getMonth (  )  const [inline]

Return the (UTC) month (1--12) of the year.

int code::CalendarDate::getSecond (  )  const [inline]

Return the second (0--61) of the minute.

std::string code::CalendarDate::getString ( bool  withSpace = true  )  const

Convert a CalendarDate object to a UTC std::string.

Parameters:
withSpace,: if it is true, the returned string looks like [2001 02/28 16:00:00 UTC] with space, otherwise it looks like 20010228-160000 without space which is prefered by XML file or for file name.

std::string code::CalendarDate::getStringForFileName (  )  const

Convert a CalendarDate object to a UTC std::string that is suitable to use as a file name.

The result looks like: 20010228-160316

Time code::CalendarDate::getTime (  )  const

Return a Time.

int code::CalendarDate::getYear (  )  const [inline]

Return the (UTC) year.

bool code::CalendarDate::isValid ( Time = 0  )  const

Indicate whether the object represents a valid date.

Parameters:
Time* if nonzero used to store the corresponding Time

static CalendarDate code::CalendarDate::LocalTime ( tm &   )  [static]

Convert from tm that refers to local time.

code::CalendarDate::operator Time (  )  const

Autoconversion to Time.

bool code::CalendarDate::operator< ( const CalendarDate  )  const

Less-than comparison operator.

bool code::CalendarDate::operator== ( const CalendarDate  )  const

Equality comparison operator.

static CalendarDate code::CalendarDate::UTC ( tm &   )  [static]

Convert from tm that refers to UTC.


Generated on Fri May 4 13:40:12 2012 for WDSS-IIw2 by  doxygen 1.4.7