YGP::ATime Class Reference

Class for time attributes. More...

Inherits YGP::AttributValue.

Inherited by YGP::ATimestamp [virtual].

List of all members.

Public Member Functions

 ATime ()
 ATime (bool now)
 ATime (const ATime &other)
 ATime (char Hour, char minute, char second) throw (std::invalid_argument)
 ATime (const char *pTime) throw (std::invalid_argument)
 ATime (const std::string &time) throw (std::invalid_argument)
 ATime (const struct tm &tm)
 ATime (const time_t &time, bool local=true)
virtual ~ATime ()
virtual void define ()
void setHour (char Hour) throw (std::invalid_argument)
void setMinute (char minute) throw (std::invalid_argument)
void setSecond (char second) throw (std::invalid_argument)
char getHour () const
char getMinute () const
char getSecond () const
Assignment methods
ATimeoperator= (const std::string &time) throw (std::invalid_argument)
ATimeoperator= (const char *pTime) throw (std::invalid_argument)
ATimeoperator= (const ATime &other)
ATimeoperator= (const struct tm &tm)
ATimeoperator= (const time_t &time)
void setGMT (const time_t &time)
virtual void readFromStream (std::istream &in) throw (std::invalid_argument)
void assign (const char *pTime, unsigned int len)
Convertion
virtual std::string toUnformattedString () const
virtual std::string toString () const
virtual std::string toString (const char *format) const
virtual struct tm toStructTM () const
time_t toSysTime () const

Static Public Member Functions

static ATime now ()

Comparison

enum  Mode { MODE_LOCALE = 0, MODE_HHMM, MODE_MMSS }
bool operator== (const ATime &other) const
bool operator!= (const ATime &other) const
bool operator< (const ATime &other) const
bool operator> (const ATime &other) const
bool operator<= (const ATime &other) const
bool operator>= (const ATime &other) const
long compare (const ATime &other) const
virtual int checkIntegrity () const
void setMode (enum Mode newMode)
enum Mode getMode () const
virtual bool maxAdapt ()
virtual bool minAdapt ()

Calculation

ATimeoperator+= (const ATime &rhs)
ATimeoperator-= (const ATime &rhs)
ATimeadd (char Hour, char minute=0, char second=0)
ATimesub (char Hour, char minute=0, char second=0)
ATime operator+ (const ATime &lhs, const ATime &rhs)
ATime operator- (const ATime &lhs, const ATime &rhs)


Detailed Description

Class for time attributes.

As every AttributValue is supports undefined values.


Member Enumeration Documentation

Compares two objects for equalnesss.


Constructor & Destructor Documentation

YGP::ATime::ATime (  )  [inline]

Default constructor; creates an undefined object.

YGP::ATime::ATime ( bool  now  ) 

Constructor; depending on the parameter the time is either set to "0:00:00" (now = false), or to the current time (now = true).

Parameters:
now Flag if current time or default start-time (1.1.1900) should be set

YGP::ATime::ATime ( const ATime other  )  [inline]

Copy constructor from another time object.

YGP::ATime::ATime ( char  Hour,
char  minute,
char  second 
) throw (std::invalid_argument)

Constructor; sets the passed time.

The object is undefined, if the passed parameters represent no valid time (e.g. Hour > 23, minute > 59 or second > 61)

Parameters:
Hour Hour for this ATime
minute Minute to set
second Second to set

YGP::ATime::ATime ( const char *  pTime  )  throw (std::invalid_argument) [inline]

Constructor from a text (unformatted).

YGP::ATime::ATime ( const std::string &  time  )  throw (std::invalid_argument) [inline]

Constructor from a text (unformatted).

YGP::ATime::ATime ( const struct tm &  tm  )  [inline]

Constructor from broken down time.

YGP::ATime::ATime ( const time_t &  time,
bool  local = true 
) [inline]

Construct from system time.

YGP::ATime::~ATime (  )  [virtual]

Destructor.


Member Function Documentation

ATime & YGP::ATime::add ( char  Hour,
char  minute = 0,
char  second = 0 
)

If this is not undefined, the passed values are added.

Overflows of seconds or minutes are corrected, overflows of the hour undefines the object. The result is returned.

Parameters:
Hour Hour to add
minute Minute to add
second Second to add
Returns:
ATime& Self

void YGP::ATime::assign ( const char *  pTime,
unsigned int  len 
)

Assignment-operator from a const char-pointer.

The time must be passed either in the local format or as HHMMSS. If the buffer does not represent a valid time an excpetion is thrown.

Parameters:
pTime Character array specifying time to assign
len Length of the passed date
Exceptions:
std::invalid_argument if the parameter does not represent a valid time
Remarks:
If the object is in MODE_HHMM or MODE_MMSS, the method also accepts the input in format HHMM or MMSS.

int YGP::ATime::checkIntegrity (  )  const [virtual]

Checks if this object represents a valid time.

Note: Even undefined times must have valid values!

Returns:
int Status; 0: OK

Reimplemented in YGP::ATimestamp.

long YGP::ATime::compare ( const ATime other  )  const

Returns the (approximated) difference in seconds between two times.

If both times are undefined, those difference is "0", if only this is undefined the result is -1, if only other is undefined 1 is returned (-> undefined times are considered as (very) old).

Parameters:
other Object to compare
Returns:
long >0 if this other; 0 if this == other; <0 else
Note:
Undefined values are considered as (incredible) old "Younger dates" (closer to the past) are considered bigger than "older dates"(further in the past; that means the numeric value of the date is compared.

virtual void YGP::ATime::define (  )  [inline, virtual]

Defining the object; setting it to a default value (of 0:00:00).

Implements YGP::AttributValue.

Reimplemented in YGP::ATimestamp.

char YGP::ATime::getHour (  )  const [inline]

Returns the hour.

char YGP::ATime::getMinute (  )  const [inline]

Returns the minute.

enum Mode YGP::ATime::getMode (  )  const [inline]

Compares two objects for equalnesss.

char YGP::ATime::getSecond (  )  const [inline]

Returns the second.

bool YGP::ATime::maxAdapt (  )  [protected, virtual]

Corrects the object after an (possible) overflows.

If the hour has an overflow true is returned, else false.

Returns:
bool True, if there´s a overflow of the hour

Reimplemented in YGP::ATimestamp.

bool YGP::ATime::minAdapt (  )  [protected, virtual]

Corrects the object after an (possible) underflows.

If the hour has an underflow. true is returned, else false.

Returns:
bool True, if there´s a underflow of hour

Reimplemented in YGP::ATimestamp.

static ATime YGP::ATime::now (  )  [inline, static]

Returns the actual time.

Reimplemented in YGP::ATimestamp.

bool YGP::ATime::operator!= ( const ATime other  )  const [inline]

Compares if two objects are not equal

ATime & YGP::ATime::operator+= ( const ATime rhs  ) 

Adds another time-value to the object.

An undefined time is treated as "0:00:00"; if both objects are undefined, the result is undefined. Overflows of seconds or minutes are corrected, overflows of the hour undefines the object.

Parameters:
rhs Value to add
Returns:
ATime& Self
Note:
If lhs is not defined this is not changed

ATime & YGP::ATime::operator-= ( const ATime rhs  ) 

Substracts another time-value from the object.

An undefined time is treated as "0:00:00"; the result is undefined if both objects are undefined. Underflows (of day or month) are corrected; underflows of of the hour undefines the object.

Parameters:
rhs Value to substract
Returns:
ATime& Self

bool YGP::ATime::operator< ( const ATime other  )  const [inline]

Checks if one object is "younger" than the other. See compare() for details.

bool YGP::ATime::operator<= ( const ATime other  )  const [inline]

Checks if one object is "younger" than or equal to the other. See compare() for details.

ATime& YGP::ATime::operator= ( const time_t &  time  )  [inline]

Assignment operator from system time (local time)

Reimplemented in YGP::ATimestamp.

ATime& YGP::ATime::operator= ( const struct tm &  tm  )  [inline]

Assignment operator from broken down time

Reimplemented in YGP::ATimestamp.

ATime & YGP::ATime::operator= ( const ATime other  ) 

Assignment-operator from another ATime object.

Parameters:
other Object to assign
Returns:
ATime& Reference to self

ATime & YGP::ATime::operator= ( const char *  pTime  )  throw (std::invalid_argument)

Assignment-operator from a const char-pointer.

The time must be passed either in the local format or as HHMMSS. If the buffer does not represent a valid time an excpetion is thrown.

Parameters:
pTime Character array specifying time to assign
Returns:
ATime& Reference to self
Exceptions:
std::invalid_argument if the parameter does not represent a valid time

Reimplemented in YGP::ATimestamp.

ATime& YGP::ATime::operator= ( const std::string &  time  )  throw (std::invalid_argument) [inline]

Assignment operator from an (unformatted) text.

Reimplemented in YGP::ATimestamp.

bool YGP::ATime::operator== ( const ATime other  )  const [inline]

Compares two objects for equalnesss.

bool YGP::ATime::operator> ( const ATime other  )  const [inline]

Checks if one object is "older" than the other. See compare() for details.

bool YGP::ATime::operator>= ( const ATime other  )  const [inline]

Checks if one object is "older" than or equal to the other. See compare() for details.

void YGP::ATime::readFromStream ( std::istream &  in  )  throw (std::invalid_argument) [virtual]

Reads the time in format hhmmss (with leading zeros) from a stream.

Parameters:
in Stream to parse
Exceptions:
invalid_argument in case of an format error

Implements YGP::AttributValue.

Reimplemented in YGP::ATimestamp.

void YGP::ATime::setGMT ( const time_t &  time  )  [inline]

Assignment operator from system time (GMT)

void YGP::ATime::setHour ( char  Hour  )  throw (std::invalid_argument)

Sets the hour of the passed valued.

Parameters:
Hour Hour to set
Exceptions:
std::invalid_argument if the parameter is bigger than 23

void YGP::ATime::setMinute ( char  minute  )  throw (std::invalid_argument)

Sets the minute to the passed value.

Parameters:
minute Minute to set
Exceptions:
std::invalid_argument if the parameter is bigger than 59

void YGP::ATime::setMode ( enum Mode  newMode  )  [inline]

Compares two objects for equalnesss.

void YGP::ATime::setSecond ( char  second  )  throw (std::invalid_argument)

Sets the second to the passed value.

Parameters:
second Second to set
Exceptions:
std::invalid_argument if the parameter is bigger than 61

ATime & YGP::ATime::sub ( char  Hour,
char  minute = 0,
char  second = 0 
)

If this is not undefined, the passed values are substracted.

Overflows of seconds or minutes are corrected, overflows of the hour undefines the object. The result is returned.

Parameters:
Hour Hour to substract
minute Minute to substract
second Second to substract
Returns:
ATime& Self

std::string YGP::ATime::toString ( const char *  format  )  const [virtual]

Converts the time into a string, in the specified format.

The parameter format can be any value accepted by the strftime library-routine.

Returns:
String-representation of ATime
Remarks:
Only dates valid for struct tm can be printed (e.g. dates after 1900)

Reimplemented in YGP::ATimestamp.

std::string YGP::ATime::toString (  )  const [virtual]

Converts the time into a string, in a format specified by the current locale.

Returns:
String-representation of ATime
Remarks:
Only dates valid for struct tm can be printed (e.g. dates after 1900)

Reimplemented from YGP::AttributValue.

Reimplemented in YGP::ATimestamp.

struct tm YGP::ATime::toStructTM (  )  const [read, virtual]

Converts the time to a struct tm.

Returns:
struct tm Time in struct tm-format; the date-part is set to zeros
Remarks:
It is not checked if the date is in the right range for a struct tm (after 1900 and before 2039)

Reimplemented in YGP::ATimestamp.

time_t YGP::ATime::toSysTime (  )  const [inline]

Converting into a system time

Reimplemented in YGP::ATimestamp.

std::string YGP::ATime::toUnformattedString (  )  const [virtual]

Converts the time into a string, in format hhmmss (each part with leading zeros).

Returns:
String-representation of ATime

Reimplemented from YGP::AttributValue.

Reimplemented in YGP::ATimestamp.


Friends And Related Function Documentation

ATime operator+ ( const ATime lhs,
const ATime rhs 
) [friend]

Returns the addition of two time-values.

An undefined time is treated as "0:00:00"; if both objects are undefined, the result is undefined. Overflows of seconds or minutes are corrected, overflows of the hour undefines the object.

Parameters:
lhs Left-hand-side of addition
rhs Right-hand-side of addition
Returns:
ATime Result of additon

ATime operator- ( const ATime lhs,
const ATime rhs 
) [friend]

Returns the substraction of two time-values.

An undefined time is treated as "0:00:00"; if both objects are undefined, the result is undefined. Underflows of seconds or minutes are corrected, underflows of the hour undefines the object.

Parameters:
lhs Left-hand-side of substraction
rhs Right-hand-side of substraction
Returns:
ATime Result of substraction


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

YGP Version 0.9.31 - Generated on Wed Nov 18 11:25:27 2009 by doxygen 1.5.8