Inherits YGP::AttributValue.
Inherited by YGP::ATimestamp [virtual]
.
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 | |
ATime & | operator= (const std::string &time) throw (std::invalid_argument) |
ATime & | operator= (const char *pTime) throw (std::invalid_argument) |
ATime & | operator= (const ATime &other) |
ATime & | operator= (const struct tm &tm) |
ATime & | operator= (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 | |
ATime & | operator+= (const ATime &rhs) |
ATime & | operator-= (const ATime &rhs) |
ATime & | add (char Hour, char minute=0, char second=0) |
ATime & | sub (char Hour, char minute=0, char second=0) |
ATime | operator+ (const ATime &lhs, const ATime &rhs) |
ATime | operator- (const ATime &lhs, const ATime &rhs) |
As every AttributValue is supports undefined values.
enum YGP::ATime::Mode |
Compares two objects for equalnesss.
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).
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)
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.
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.
Hour | Hour to add | |
minute | Minute to add | |
second | Second to add |
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.
pTime | Character array specifying time to assign | |
len | Length of the passed date |
std::invalid_argument | if the parameter does not represent a valid time |
int YGP::ATime::checkIntegrity | ( | ) | const [virtual] |
Checks if this object represents a valid time.
Note: Even undefined times must have valid values!
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).
other | Object to compare |
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.
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.
Reimplemented in YGP::ATimestamp.
static ATime YGP::ATime::now | ( | ) | [inline, static] |
bool YGP::ATime::operator!= | ( | const ATime & | other | ) | const [inline] |
Compares if two objects are not equal
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.
rhs | Value to add |
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.
rhs | Value to substract |
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] |
ATime& YGP::ATime::operator= | ( | const struct tm & | tm | ) | [inline] |
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.
pTime | Character array specifying time to assign |
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] |
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.
in | Stream to parse |
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.
Hour | Hour to set |
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.
minute | Minute to set |
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.
second | Second to set |
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.
Hour | Hour to substract | |
minute | Minute to substract | |
second | Second to substract |
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.
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.
Reimplemented from YGP::AttributValue.
Reimplemented in YGP::ATimestamp.
struct tm YGP::ATime::toStructTM | ( | ) | const [read, virtual] |
Converts the time to a struct tm.
Reimplemented in YGP::ATimestamp.
time_t YGP::ATime::toSysTime | ( | ) | const [inline] |
std::string YGP::ATime::toUnformattedString | ( | ) | const [virtual] |
Converts the time into a string, in format hhmmss (each part with leading zeros).
Reimplemented from YGP::AttributValue.
Reimplemented in YGP::ATimestamp.
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.
lhs | Left-hand-side of addition | |
rhs | Right-hand-side of addition |
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.
lhs | Left-hand-side of substraction | |
rhs | Right-hand-side of substraction |