return ret_val;
}
+bool Date::before_or_equal_year(Date *date2) {
+ bool ret_val;
+ string s1;
+ string s2;
+
+ ret_val = (this->year <= date2->year);
+ return ret_val;
+}
+
+bool Date::before_or_equal_month(Date *date2) {
+ bool ret_val;
+ string s1;
+ string s2;
+
+ ret_val = false;
+ if (this->year < date2->month) {
+ ret_val = true;
+ }
+ else {
+ if ((this->year == date2->year) &&
+ (this->month <= date2->month)) {
+ ret_val = true;
+ }
+ }
+ return ret_val;
+}
+
+bool Date::before_or_equal_day(Date *date2) {
+ bool ret_val;
+ string s1;
+ string s2;
+
+ ret_val = false;
+ if (date2 != NULL) {
+ s1 = this->to_sortable_day_string();
+ s2 = date2->to_sortable_day_string();
+ if (s1.compare(s2) <= 0) {
+ ret_val = true;
+ }
+ }
+ return ret_val;
+}
+
+bool Date::before_or_equal_hour(Date *date2) {
+ bool ret_val;
+ string s1;
+ string s2;
+
+ ret_val = false;
+ if (date2 != NULL) {
+ s1 = this->to_sortable_hour_string();
+ s2 = date2->to_sortable_hour_string();
+ if (s1.compare(s2) <= 0) {
+ ret_val = true;
+ }
+ }
+ return ret_val;
+}
+
+bool Date::before_or_equal_min(Date *date2) {
+ bool ret_val;
+ string s1;
+ string s2;
+
+ ret_val = false;
+ if (date2 != NULL) {
+ s1 = this->to_sortable_min_string();
+ s2 = date2->to_sortable_min_string();
+ if (s1.compare(s2) <= 0) {
+ ret_val = true;
+ }
+ }
+ return ret_val;
+}
+
+bool Date::before_or_equal(Date *date2) {
+ bool ret_val;
+ string s1;
+ string s2;
+
+ ret_val = false;
+ if (date2 != NULL) {
+ s1 = this->to_sortable_string();
+ s2 = date2->to_sortable_string();
+ if (s1.compare(s2) <= 0) {
+ ret_val = true;
+ }
+ }
+ return ret_val;
+}
+
void Date::tomorrow() {
if ((month > 0) &&
(month <= 12)) {
else {
day = 1;
month++;
- if (month == 12) {
+ if (month > 12) {
year++;
month = 1;
}
}
}
+string Date::to_sortable_day_string() {
+ char buffer[30];
+
+
+ string ret_val;
+
+ sprintf(buffer, "%016d%02d%02d", year, month, day);
+ ret_val = buffer;
+ return ret_val;
+}
+
+string Date::to_sortable_hour_string() {
+ char buffer[30];
+ string ret_val;
+
+ sprintf(buffer, "%016d%02d%02d%02d", year, month, day, hour);
+ ret_val = buffer;
+ return ret_val;
+}
+
+string Date::to_sortable_min_string() {
+ char buffer[30];
+ string ret_val;
+
+ sprintf(buffer, "%016d%02d%02d%02d%02d", year, month, day, hour, min);
+ ret_val = buffer;
+ return ret_val;
+}
+
string Date::to_sortable_string() {
char buffer[30];
string ret_val;