40 #include <Bpp/Text/TextTools.h> 50 Date::Date(
const int day,
const int month,
const int year)
throw (BadIntegerException) : day_(day),
54 if (day < 1 || day > 31)
55 throw (BadIntegerException(
"Date::Date: day must be in [1;31].", day));
56 if (month < 1 || month > 12)
57 throw (BadIntegerException(
"Date::Date: month must be in [1;12].", month));
61 month_(date.getMonth()),
62 year_(date.getYear()) {}
78 void Date::setDate(
const int day,
const int month,
const int year)
throw (BadIntegerException)
80 if (day >= 1 && day <= 31)
83 throw (BadIntegerException(
"Date::Date: day must be in [1;31].", day));
84 if (month >= 1 && month <= 12)
87 throw (BadIntegerException(
"Date::Date: month must be in [1;12].", month));
98 if (month >= 1 && month <= 12)
101 throw (BadIntegerException(
"Date::Date: month must be in [1;12].", month));
106 if (day >= 1 && day <= 31)
109 throw (BadIntegerException(
"Date::Date: day must be in [1;31].", day));
114 string date, uDay =
"", uMonth =
"";
119 date = uDay + TextTools::toString(
day_) + uMonth + TextTools::toString(
month_) + TextTools::toString(
year_);
void setDate(const int day, const int month, const int year)
Set the Date.
Date & operator=(const Date &date)
The Date copy operator.
void setMonth(const int month)
Set the month.
int getDay() const
Get the day as an int.
~Date()
Destroy the Date object.
void setYear(const int year)
Set the year.
int getMonth() const
Get the month as an int.
void setDay(const int day)
Set the day.
std::string getDateStr() const
Get the Date as a string.
int getYear() const
Get the Year as an int.
Date(const int day=1, const int month=1, const int year=2000)
Build a new Date from three values.
bool operator==(const Date &date) const
The == operator.
bool operator<(const Date &date) const
The < operator.