Inherits YGP::ADate, and YGP::ATime.
Public Member Functions | |
| ATimestamp () | |
| ATimestamp (bool now) | |
| ATimestamp (const ATimestamp &other) | |
| ATimestamp (char Day, char Month, int Year, char Hour, char minute, char second) throw (std::invalid_argument) | |
| ATimestamp (const char *pStamp) throw (std::invalid_argument) | |
| ATimestamp (const std::string &stamp) throw (std::invalid_argument) | |
| ATimestamp (const struct tm &tm) | |
| ATimestamp (const time_t &stamp, bool local=true) | |
| virtual | ~ATimestamp () |
| bool | isDefined () const |
| virtual void | undefine () |
| virtual void | define () |
| int | checkIntegrity () const |
Assignment methods | |
| ATimestamp & | operator= (const std::string &stamp) throw (std::invalid_argument) |
| ATimestamp & | operator= (const char *pValue) throw (std::invalid_argument) |
| ATimestamp & | operator= (const struct tm &tm) |
| ATimestamp & | operator= (const ATimestamp &other) |
| ATimestamp & | operator= (const time_t &stamp) |
| ATimestamp & | assignGMT (const time_t &stamp) |
| virtual void | readFromStream (std::istream &in) throw (std::invalid_argument) |
Convertion | |
| virtual std::string | toUnformattedString () const |
| virtual std::string | toString () const |
| virtual std::string | toString (const char *format) const |
| time_t | toSysTime () const |
| struct tm | toStructTM () const |
| time_t | toGMTTime () const |
| time_t | toLocalTime () const |
Comparison | |
| bool | operator== (const ATimestamp &other) const |
| bool | operator!= (const ATimestamp &other) const |
| bool | operator< (const ATimestamp &other) const |
| bool | operator> (const ATimestamp &other) const |
| bool | operator<= (const ATimestamp &other) const |
| bool | operator>= (const ATimestamp &other) const |
| long | compare (const ATimestamp &other) const |
Static Public Member Functions | |
| static ATimestamp | now () |
Protected Member Functions | |
| virtual bool | maxAdapt () |
| virtual bool | minAdapt () |
Friends | |
| std::istream & | operator>> (std::istream &in, ATimestamp &inValue) |
| std::ostream & | operator<< (std::ostream &out, const ATimestamp &outValue) |
Calculation | |
| ATimestamp & | operator+= (const ATimestamp &rhs) |
| ATimestamp & | operator-= (const ATimestamp &rhs) |
| ATimestamp & | add (char Day, char Month=0, int Year=0, char Hour=0, char minute=0, char second=0) |
| ATimestamp & | sub (char Day, char month=0, int Year=0, char Hour=0, char minute=0, char second=0) |
| ATimestamp | operator+ (const ATimestamp &lhs, const ATimestamp &rhs) |
| ATimestamp | operator- (const ATimestamp &lhs, const ATimestamp &rhs) |
As every AttributValue is supports undefined values.
| YGP::ATimestamp::ATimestamp | ( | ) |
Defaultconstructor; the timestamp is not defined.
| YGP::ATimestamp::ATimestamp | ( | bool | now | ) |
Constructor; depending on the parameter the timestamp is either set to the 1st of January, 1900 0:00:00 (now = false), or to the current time (now = true).
| now | Flag if current time or default time (1.1.1900) should be set |
| YGP::ATimestamp::ATimestamp | ( | const ATimestamp & | other | ) | [inline] |
Copy constructor from another ATimestamp object.
| YGP::ATimestamp::ATimestamp | ( | char | Day, | |
| char | Month, | |||
| int | Year, | |||
| 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 date/time-combination (e.g. Hour > 23, minute > 59, second > 61 or day > 31).
| Day | Day for this object | |
| Month | Month of this object | |
| Year | Year of this object | |
| Hour | Hour of this object | |
| minute | Minute of this object | |
| second | Other time-parameters |
| YGP::ATimestamp::ATimestamp | ( | const char * | pStamp | ) | throw (std::invalid_argument) [inline] |
Constructor from an (unformatted) text.
| YGP::ATimestamp::ATimestamp | ( | const std::string & | stamp | ) | throw (std::invalid_argument) [inline] |
Constructor from an (unformatted) text.
| YGP::ATimestamp::ATimestamp | ( | const struct tm & | tm | ) | [inline] |
Constructor from a broken down time.
| YGP::ATimestamp::ATimestamp | ( | const time_t & | stamp, | |
| bool | local = true | |||
| ) | [inline] |
Constructor from a system time.
| YGP::ATimestamp::~ATimestamp | ( | ) | [virtual] |
Destructor.
| ATimestamp & YGP::ATimestamp::add | ( | char | Day, | |
| char | Month = 0, |
|||
| int | Year = 0, |
|||
| char | Hour = 0, |
|||
| char | minute = 0, |
|||
| char | second = 0 | |||
| ) |
If this is not undefined, the passed values are added.
Overflows are corrected. The result is returned. In counterpart to the mathematic operators (+ and -) this method does not change the object if it is undefined!
| Day | Day to add | |
| Month | Month to add | |
| Year | Year to add | |
| Hour | Hour to add | |
| minute | Minute to add | |
| second | Second to add |
| ATimestamp& YGP::ATimestamp::assignGMT | ( | const time_t & | stamp | ) | [inline] |
Assignment operator from an (unformatted) text.
| int YGP::ATimestamp::checkIntegrity | ( | ) | const [virtual] |
Checks if this object represents a valid timestamp.
Note: Even undefined times must have valid values!
Reimplemented from YGP::ADate.
| long YGP::ATimestamp::compare | ( | const ATimestamp & | other | ) | const |
Returns the (approximated) difference in days, or - if the day is equal - in seconds between two timestamps.
"Younger times" (closer to the past) are considered bigger than "older times" (further in the past; that means the numeric value of the time is compared (e.g.: "yesterday" < "now" < "tomorrow").
If both objects are undefined, those difference is "0", if only this is undefined the result is MINLONG, if only other is undefined MAXLONG is returned (-> undefined times are considered to be very old).
| other | Object to compare |
| virtual void YGP::ATimestamp::define | ( | ) | [inline, virtual] |
Defining the object; setting it to a default value (of 1/1/1900 0:0:0).
Reimplemented from YGP::ADate.
| bool YGP::ATimestamp::isDefined | ( | ) | const [inline] |
| bool YGP::ATimestamp::maxAdapt | ( | ) | [protected, virtual] |
Corrects the object after overflows.
If the the object is integer after the operation, true is returned (else false).
Reimplemented from YGP::ADate.
| bool YGP::ATimestamp::minAdapt | ( | ) | [protected, virtual] |
Corrects the object after underflows.
If the the object is integer after the operation, true is returned (else false).
Reimplemented from YGP::ADate.
| static ATimestamp YGP::ATimestamp::now | ( | ) | [inline, static] |
| bool YGP::ATimestamp::operator!= | ( | const ATimestamp & | other | ) | const [inline] |
Compares if two objects are not equal
| ATimestamp & YGP::ATimestamp::operator+= | ( | const ATimestamp & | rhs | ) |
Adds another timestamp-value to the object.
An undefined timestamp is treated as "0.0.0 0:00:00"; if both objects are undefined, the result is undefined. Overflows are corrected.
| rhs | Value to add |
| ATimestamp & YGP::ATimestamp::operator-= | ( | const ATimestamp & | rhs | ) |
Substracts another timestamp-value to the object.
An undefined timestamp is treated as "0.0.0 0:00:00"; if both objects are undefined, the result is undefined. Underflows are corrected.
| rhs | Value to substract |
| bool YGP::ATimestamp::operator< | ( | const ATimestamp & | other | ) | const [inline] |
Checks if one object is "younger" than the other. See compare() for details.
| bool YGP::ATimestamp::operator<= | ( | const ATimestamp & | other | ) | const [inline] |
Checks if one object is "younger" than or equal to the other. See compare() for details.
| ATimestamp& YGP::ATimestamp::operator= | ( | const time_t & | stamp | ) | [inline] |
| ATimestamp & YGP::ATimestamp::operator= | ( | const ATimestamp & | other | ) |
Assignment-operator from another timestamp object.
| other | Object to assign |
| ATimestamp & YGP::ATimestamp::operator= | ( | const struct tm & | tm | ) |
Assignment-operator; assigns the values from the passed struct tm.
| tm | Object to assign as char-string |
Reimplemented from YGP::ADate.
| ATimestamp & YGP::ATimestamp::operator= | ( | const char * | pValue | ) | throw (std::invalid_argument) |
Assignment-operator from an const char-pointer.
The timestamp must be passed as DDMMY[Y...] hhmmss. If the buffer does not represent a valid timestamp, an exception is thrown.
| pValue | Character array specifying timestamp to assign |
| std::invalid_argument | if the parameters has a wrong format |
Reimplemented from YGP::ADate.
| ATimestamp& YGP::ATimestamp::operator= | ( | const std::string & | stamp | ) | throw (std::invalid_argument) [inline] |
| bool YGP::ATimestamp::operator== | ( | const ATimestamp & | other | ) | const [inline] |
Compares two objects for equalnesss
| bool YGP::ATimestamp::operator> | ( | const ATimestamp & | other | ) | const [inline] |
Checks if one object is "older" than the other. See compare() for details.
| bool YGP::ATimestamp::operator>= | ( | const ATimestamp & | other | ) | const [inline] |
Checks if one object is "older" than or equal to the other. See compare() for details.
| void YGP::ATimestamp::readFromStream | ( | std::istream & | in | ) | throw (std::invalid_argument) [virtual] |
Reads the timestamp in the format DDMMY[Y.
..] hhmmss (with leading zeros) from a stream. If the input is not a valid timestamp an exception is thrown.
| in | Stream to parse |
| std::invalid_argument | in case of a format error |
Reimplemented from YGP::ADate.
| ATimestamp & YGP::ATimestamp::sub | ( | char | Day, | |
| char | Month = 0, |
|||
| int | Year = 0, |
|||
| char | Hour = 0, |
|||
| char | minute = 0, |
|||
| char | second = 0 | |||
| ) |
If this is not undefined, the passed values are substracted.
Underflows are corrected. The result is returned. In counterpart to the mathematic operators (+ and -) this method does not change the object if it is undefined!
| Day | Day to substract | |
| Month | Month to substract | |
| Year | Year to substract | |
| Hour | Hour to substract | |
| minute | Minute to substract | |
| second | Second to substract |
| time_t YGP::ATimestamp::toGMTTime | ( | ) | const |
Converts the object to a system-timestructure (as GMT).
| time_t YGP::ATimestamp::toLocalTime | ( | ) | const [inline] |
Converting into a system time (local time)
| std::string YGP::ATimestamp::toString | ( | const char * | format | ) | const [virtual] |
Converts the object into a string, in the specified format.
The parameter format can be any value accepted by the strftime library-routine.
struct tm can be printed (e.g. dates after 1900) Reimplemented from YGP::ADate.
| std::string YGP::ATimestamp::toString | ( | ) | const [virtual] |
Converts the object into a string, in a format specified by the current locale.
struct tm can be printed (e.g. dates after 1900) Reimplemented from YGP::ADate.
| struct tm YGP::ATimestamp::toStructTM | ( | ) | const [read, virtual] |
Converts the object to a struct tm.
struct tm (after 1900 and before 2039) Reimplemented from YGP::ADate.
| time_t YGP::ATimestamp::toSysTime | ( | ) | const [inline] |
| std::string YGP::ATimestamp::toUnformattedString | ( | ) | const [virtual] |
Converts the object into a string, in the format DDMMYYYY[.
..] hhmmss.
Reimplemented from YGP::ADate.
| virtual void YGP::ATimestamp::undefine | ( | ) | [inline, virtual] |
Undefines the object.
Undefines the object (has no value anymore)
Reimplemented from YGP::AttributValue.
| ATimestamp operator+ | ( | const ATimestamp & | lhs, | |
| const ATimestamp & | rhs | |||
| ) | [friend] |
Returns the addition of two timestamp-values.
An undefined time is treated as "0.0.0 0:00:00"; if both objects are undefined, the result is undefined. Overflows are corrected.
| lhs | Left-hand-side of addition | |
| rhs | Right-hand-side of addition |
| ATimestamp operator- | ( | const ATimestamp & | lhs, | |
| const ATimestamp & | rhs | |||
| ) | [friend] |
Returns the substraction of two timestamp-values.
An undefined time is treated as "0.0.0 0:00:00"; if both objects are undefined, the result is undefined. Underflows are corrected.
| lhs | Left-hand-side of substraction | |
| rhs | Right-hand-side of substraction |
| std::ostream& operator<< | ( | std::ostream & | out, | |
| const ATimestamp & | outValue | |||
| ) | [friend] |
Output to a stream using the toUnformattedString() method.
| std::istream& operator>> | ( | std::istream & | in, | |
| ATimestamp & | inValue | |||
| ) | [friend] |
Input from a stream using the readFromStream() method.