Inherits YGP::AttributValue.
Inherited by YGP::ADate.
Public Member Functions | |
AYear () | |
AYear (const AYear &other) | |
AYear (int Year) | |
AYear (const char *pYear) throw (std::invalid_argument) | |
AYear (const std::string &year) throw (std::invalid_argument) | |
virtual | ~AYear () |
virtual void | define () |
Assignment methods | |
AYear & | operator= (const std::string &year) throw (std::invalid_argument) |
AYear & | operator= (const AYear &other) |
AYear & | operator= (const char *pValue) throw (std::invalid_argument) |
AYear & | operator= (int Year) |
virtual void | readFromStream (std::istream &in) throw (std::invalid_argument) |
Query methods | |
operator int () const | |
Convertion | |
virtual std::string | toUnformattedString () const |
Comparison | |
bool | operator== (const AYear &other) const |
bool | operator!= (const AYear &other) const |
bool | operator< (const AYear &other) const |
bool | operator> (const AYear &other) const |
bool | operator<= (const AYear &other) const |
bool | operator>= (const AYear &other) const |
long | compare (const AYear &other) const |
Protected Attributes | |
int | year |
Calculation | |
AYear & | operator+= (const AYear &rhs) |
AYear & | operator-= (const AYear &rhs) |
AYear | operator+ (const AYear &lhs, const AYear &rhs) |
AYear | operator- (const AYear &lhs, const AYear &rhs) |
Usefull utility-functions | |
bool | isLeapYear () const |
static bool | isLeapYear (int year) |
As every AttributValue is supports undefined values.
YGP::AYear::AYear | ( | ) | [inline] |
Default constructor; creates an undefined object.
YGP::AYear::AYear | ( | const AYear & | other | ) | [inline] |
Copy constructor from another year object.
YGP::AYear::AYear | ( | int | Year | ) | [inline] |
Year | Constructor; sets the passed year |
YGP::AYear::AYear | ( | const char * | pYear | ) | throw (std::invalid_argument) [inline] |
Constructor from a text.
YGP::AYear::AYear | ( | const std::string & | year | ) | throw (std::invalid_argument) [inline] |
Constructor from a text.
YGP::AYear::~AYear | ( | ) | [virtual] |
Destructor.
long YGP::AYear::compare | ( | const AYear & | other | ) | const |
Returns the (approximated) difference in days between two years.
"Younger years" (closer to the past) are considered bigger than "older years" (further in the past; that means the numeric value of the year is compared (e.g.: "last year" < "this year" < "next year").
If both years are undefined, their difference is "0", if only this is undefined the result is -1; if other is undefined 1 is returned.
other | Object to compare |
virtual void YGP::AYear::define | ( | ) | [inline, virtual] |
Defining the object; setting it to a default value (of 1900
).
Implements YGP::AttributValue.
Reimplemented in YGP::ADate, and YGP::ATimestamp.
bool YGP::AYear::isLeapYear | ( | ) | const [inline] |
Tests, if the actual year is a leap year
bool YGP::AYear::isLeapYear | ( | int | year | ) | [static] |
Returns the maximal day of the specified month
(in the passed year
).
Checks if the passed year is a leap-year (years which can be divided by 4; except if it is also divideable by 100).
year | Year to check |
YGP::AYear::operator int | ( | ) | const [inline] |
Casting to an int.
bool YGP::AYear::operator!= | ( | const AYear & | other | ) | const [inline] |
Compares if two objects are not equal
Adds another year-value to the year-object.
An undefined year 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 year-value from the year-object.
An undefined year 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::AYear::operator< | ( | const AYear & | other | ) | const [inline] |
Checks if one object is "younger" than the other. See compare() for details.
bool YGP::AYear::operator<= | ( | const AYear & | other | ) | const [inline] |
Checks if one object is "younger" than or equal to the other. See compare() for details.
AYear& YGP::AYear::operator= | ( | int | Year | ) | [inline] |
Assignment operator from an (unformatted) text.
AYear & YGP::AYear::operator= | ( | const char * | pValue | ) | throw (std::invalid_argument) |
Assignment-operator from a const char-pointer.
The year must be passed as Y[Y...]
. If the buffer does not represent a valid year, an exception is thrown.
pValue | Character array holding year to assign |
std::invalid_argument | if the characters don't represent a valid year |
Reimplemented in YGP::ADate, and YGP::ATimestamp.
AYear& YGP::AYear::operator= | ( | const std::string & | year | ) | throw (std::invalid_argument) [inline] |
bool YGP::AYear::operator== | ( | const AYear & | other | ) | const [inline] |
Compares two objects for equalnesss
bool YGP::AYear::operator> | ( | const AYear & | other | ) | const [inline] |
Checks if one object is "older" than the other. See compare() for details.
bool YGP::AYear::operator>= | ( | const AYear & | other | ) | const [inline] |
Checks if one object is "older" than or equal to the other. See compare() for details.
void YGP::AYear::readFromStream | ( | std::istream & | in | ) | throw (std::invalid_argument) [virtual] |
Reads a year 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 |
Implements YGP::AttributValue.
Reimplemented in YGP::ADate, and YGP::ATimestamp.
std::string YGP::AYear::toUnformattedString | ( | ) | const [virtual] |
Converts the year into a string, in the format DDMMYYYY[.
..]; each entry is filled up with zeros.
Reimplemented from YGP::AttributValue.
Reimplemented in YGP::ADate, and YGP::ATimestamp.
Adds two year-values and returns the result.
An undefined year 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 year-values and returns the result.
An undefined year 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 |
int YGP::AYear::year [protected] |
Stores the year.