Inherits YGP::AYear.
Inherited by YGP::ATimestamp [virtual]
.
Public Member Functions | |
ADate () | |
ADate (bool now) | |
ADate (const ADate &other) | |
ADate (char Day, char Month, int Year) throw (std::invalid_argument) | |
ADate (const char *pDate) throw (std::invalid_argument) | |
ADate (const std::string &date) throw (std::invalid_argument) | |
ADate (const struct tm &tm) | |
ADate (const time_t &date) | |
virtual | ~ADate () |
virtual void | define () |
void | setDay (char Day) throw (std::invalid_argument) |
void | setMonth (char Month) throw (std::invalid_argument) |
void | setYear (int Year) |
Assignment methods | |
ADate & | operator= (const std::string &date) throw (std::invalid_argument) |
ADate & | operator= (const struct tm &date) |
ADate & | operator= (const time_t &date) |
ADate & | operator= (const ADate &other) |
ADate & | operator= (const char *pValue) throw (std::invalid_argument) |
void | assign (const char *pTime, unsigned int len) |
virtual void | readFromStream (std::istream &in) throw (std::invalid_argument) |
Query methods | |
char | getDay () const |
char | getMonth () const |
int | getYear () const |
Convertion | |
virtual std::string | toUnformattedString () const |
virtual std::string | toString () const |
virtual std::string | toString (const char *format) const |
time_t | toSysTime () const |
virtual struct tm | toStructTM () const |
Comparison | |
bool | operator== (const ADate &other) const |
bool | operator!= (const ADate &other) const |
bool | operator< (const ADate &other) const |
bool | operator> (const ADate &other) const |
bool | operator<= (const ADate &other) const |
bool | operator>= (const ADate &other) const |
long | compare (const ADate &other) const |
Static Public Member Functions | |
static ADate | today () |
Protected Member Functions | |
void | incDay () |
void | decDay () |
virtual bool | minAdapt () |
virtual bool | maxAdapt () |
Calculation | |
ADate & | operator+= (const ADate &rhs) |
ADate & | operator-= (const ADate &rhs) |
ADate & | add (signed char Day, signed char Month=0, int Year=0) |
ADate & | sub (signed char Day, signed char month=0, int Year=0) |
ADate | operator+ (const ADate &lhs, const ADate &rhs) |
ADate | operator- (const ADate &lhs, const ADate &rhs) |
Usefull utility-functions | |
char | maxDayOf () const |
virtual int | checkIntegrity () const |
static char | maxDayOf (char month, int year) |
As every AYear is supports undefined values.
YGP::ADate::ADate | ( | ) | [inline] |
Default constructor; creates an undefined object.
YGP::ADate::ADate | ( | bool | now | ) |
Constructor; depending on the parameter the date is either set to the first of January, 1900 (now = false), or to the current day (now = true).
now | Flag which date to set (1900/1/1 (false) or now (true)) |
YGP::ADate::ADate | ( | const ADate & | other | ) | [inline] |
Copy constructor from another date object.
YGP::ADate::ADate | ( | char | Day, | |
char | Month, | |||
int | Year | |||
) | throw (std::invalid_argument) |
Constructor; sets the passed date.
The date is undefined, if the passed parameters represent no valid day.
Day | Day for this ADate | |
Month | Month | |
Year | Year to set |
std::invalid_argument | in case of an invalid input |
YGP::ADate::ADate | ( | const char * | pDate | ) | throw (std::invalid_argument) [inline] |
Constructor from a text (unformatted).
YGP::ADate::ADate | ( | const std::string & | date | ) | throw (std::invalid_argument) [inline] |
Constructor from a text (unformatted).
YGP::ADate::ADate | ( | const struct tm & | tm | ) | [inline] |
Constructor from broken down time.
YGP::ADate::ADate | ( | const time_t & | date | ) | [inline] |
Construct from system time.
YGP::ADate::~ADate | ( | ) | [virtual] |
Destructor.
ADate & YGP::ADate::add | ( | signed char | Day, | |
signed char | Month = 0 , |
|||
int | Year = 0 | |||
) |
If this is not undefined, the passed values are added (with attention to overflows).
The result is returned.
Day | Day to add | |
Month | Month to add | |
Year | Year to add |
void YGP::ADate::assign | ( | const char * | pDate, | |
unsigned int | len | |||
) |
Assignment-operator from a const char-pointer.
The date must be passed either in the local format or as DDMMY[...}. If the buffer does not represent a valid date an excpetion is thrown.
pDate | Character array specifying date to assign | |
len | Length of the passed date |
std::invalid_argument | if the parameter does not represent a valid date |
int YGP::ADate::checkIntegrity | ( | ) | const [virtual] |
Checks if this object represents a valid date.
Reimplemented in YGP::ATimestamp.
long YGP::ADate::compare | ( | const ADate & | other | ) | const |
Returns the (approximated) difference in days between two dates.
"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 (e.g.: "yesterday" < "today" < "tomorrow").
If both dates are undefined, those difference is "0", if only this is undefined the result is MINLONG; if other is undefined MAXLONG is returned (-> undefined dates are considered as (very) old).
other | Object to compare |
void YGP::ADate::decDay | ( | ) | [inline, protected] |
Decreases the day.
virtual void YGP::ADate::define | ( | ) | [inline, virtual] |
Defining the object; setting it to a default value (of 1/1/1900
).
Reimplemented from YGP::AYear.
Reimplemented in YGP::ATimestamp.
char YGP::ADate::getDay | ( | ) | const [inline] |
Returns the actual day.
char YGP::ADate::getMonth | ( | ) | const [inline] |
Returns the actual month.
int YGP::ADate::getYear | ( | ) | const [inline] |
Returns the actual year.
void YGP::ADate::incDay | ( | ) | [inline, protected] |
Increases the day.
bool YGP::ADate::maxAdapt | ( | ) | [protected, virtual] |
Corrects the object after an (possible) overflows.
If the object is integer after the operation, true is returned.
Reimplemented in YGP::ATimestamp.
char YGP::ADate::maxDayOf | ( | char | month, | |
int | year | |||
) | [static] |
Returns the maximal day for the the passed month/year-combination.
month | Month to check | |
year | Year to check |
char YGP::ADate::maxDayOf | ( | ) | const [inline] |
Returns the maximal day of the specified month
(in the passed year
).
bool YGP::ADate::minAdapt | ( | ) | [protected, virtual] |
Corrects the object after an (possible) underflows.
If the object is integer after the operation, true is returned.
Reimplemented in YGP::ATimestamp.
bool YGP::ADate::operator!= | ( | const ADate & | other | ) | const [inline] |
Compares if two objects are not equal
Adds another date-value to the date-object.
An undefined date is treated as 0.0.0
; so only if both objects are undefined, the result is (remains) undefined. Overflows (of day or month) are corrected.
rhs | Value to add |
Substracts another date-value from the date-object.
An undefined date is treated as 0.0.0
; the result is (remains) undefined if both objects are undefined. Underflows (of day or month) are corrected.
rhs | Value to substract |
bool YGP::ADate::operator< | ( | const ADate & | other | ) | const [inline] |
Checks if one object is "younger" than the other. See compare() for details.
bool YGP::ADate::operator<= | ( | const ADate & | other | ) | const [inline] |
Checks if one object is "younger" than or equal to the other. See compare() for details.
ADate & YGP::ADate::operator= | ( | const char * | pValue | ) | throw (std::invalid_argument) |
Assignment-operator from a const char-pointer.
The date must be passed as DDMMY[Y...]
. If the buffer does not represent a valid day, an exception is thrown.
pValue | Character array holding date to assign |
std::invalid_argument | if the characters don't represent a valid date |
Reimplemented from YGP::AYear.
Reimplemented in YGP::ATimestamp.
ADate& YGP::ADate::operator= | ( | const time_t & | date | ) | [inline] |
ADate & YGP::ADate::operator= | ( | const struct tm & | date | ) |
Assignment operator from a broken down time structure.
date | Structure holding the date to assign |
Reimplemented in YGP::ATimestamp.
ADate& YGP::ADate::operator= | ( | const std::string & | date | ) | throw (std::invalid_argument) [inline] |
Assignment operator from an (unformatted) text.
Reimplemented from YGP::AYear.
Reimplemented in YGP::ATimestamp.
bool YGP::ADate::operator== | ( | const ADate & | other | ) | const [inline] |
Compares two objects for equalnesss
bool YGP::ADate::operator> | ( | const ADate & | other | ) | const [inline] |
Checks if one object is "older" than the other. See compare() for details.
bool YGP::ADate::operator>= | ( | const ADate & | other | ) | const [inline] |
Checks if one object is "older" than or equal to the other. See compare() for details.
void YGP::ADate::readFromStream | ( | std::istream & | in | ) | throw (std::invalid_argument) [virtual] |
Reads a date as DDMMY[Y.
..] from a stream. If the input is not valid, an exception is thrown.
in:Stream | to parse |
std::invalid_argument | in case of an invalid input |
Reimplemented from YGP::AYear.
Reimplemented in YGP::ATimestamp.
void YGP::ADate::setDay | ( | char | Day | ) | throw (std::invalid_argument) |
Sets the day to the passed value.
If the date is not valid, it is set to undefined.
Day | Day to set |
void YGP::ADate::setMonth | ( | char | Month | ) | throw (std::invalid_argument) |
Sets the month to the passed value.
If the date is not valid, it is set to undefined.
Month | Month to set |
void YGP::ADate::setYear | ( | int | Year | ) | [inline] |
Sets the year of the date object.
ADate & YGP::ADate::sub | ( | signed char | Day, | |
signed char | Month = 0 , |
|||
int | Year = 0 | |||
) |
If this is defined, the passed values are substracted (with attention to underflows).
The result is returned.
Day | Day to substract | |
Month | Month to substract | |
Year | Year to substract |
static ADate YGP::ADate::today | ( | ) | [inline, static] |
Returns the current date.
std::string YGP::ADate::toString | ( | const char * | format | ) | const [virtual] |
Converts the date into a string, in the specified format.
The parameter format can be any value accepted by the strftime
std::string String-representation of ADate
struct tm
can be printed (e.g. dates after 1900) Reimplemented in YGP::ATimestamp.
std::string YGP::ADate::toString | ( | ) | const [virtual] |
Converts the date into a string, in the format specified by the current locale.
struct tm
can be printed (e.g. dates after 1900) Reimplemented from YGP::AttributValue.
Reimplemented in YGP::ATimestamp.
struct tm YGP::ADate::toStructTM | ( | ) | const [read, virtual] |
Converting to a struct tm.
Reimplemented in YGP::ATimestamp.
time_t YGP::ADate::toSysTime | ( | ) | const [inline] |
std::string YGP::ADate::toUnformattedString | ( | ) | const [virtual] |
Converts the date into a string, in the format DDMMYYYY[.
..]; each entry is filled up with zeros.
Reimplemented from YGP::AYear.
Reimplemented in YGP::ATimestamp.
Adds two date-values and returns the result.
An undefined date is treated as "0.0.0"; the result is (remains) undefined if both objects are undefined. Overflows (of day or month) are corrected.
lhs | Left-hand-side of addition | |
rhs | Right-hand-side of addition |
Substracts two date-values and returns the result.
An undefined date is treated as "0.0.0"; the result is (remains) undefined if both objects are undefined. Overflows (of day or month) are corrected.
lhs | Left-hand-side of substraction | |
rhs | Right-hand-side of substraction |