Website Summary Files Commits Branches @commit @diff @stats
path: root / src / DateTime / DateTime.cpp
diff options
context:
space:
mode:
Commit1353fabeb2eee2f55e8457d74c4add4d5a4c0c66 (patch)
Author
 Syndamia <kamen.d.mladenov@protonmail.com>
2022-05-01 09:20:52 +0300
Committer
 Syndamia <kamen.d.mladenov@protonmail.com>
2022-05-01 09:20:52 +0300
Filesea984fd6d9fa1d8a161e1c6e75b5fd7b84d2f7cf /src/DateTime/DateTime.cpp
FMI-OOP-P1_TicketSystem-1353fabeb2eee2f55e8457d74c4add4d5a4c0c66.tar
FMI-OOP-P1_TicketSystem-1353fabeb2eee2f55e8457d74c4add4d5a4c0c66.tar.gz
FMI-OOP-P1_TicketSystem-1353fabeb2eee2f55e8457d74c4add4d5a4c0c66.zip
Parent492fc44e1667a2a5d7afd67bab4a14b75a12cb0a (diff)
Autocommit at 01.05.2022 @ 09:20
1 files changed, 11 insertions, 8 deletions
-rw-r--r--src/DateTime/DateTime.cpp19
diff --git a/src/DateTime/DateTime.cpp b/src/DateTime/DateTime.cpp
index 96e20b3..a7f0cc5 100644
--- a/src/DateTime/DateTime.cpp
+++ b/src/DateTime/DateTime.cpp
@@ -25,14 +25,13 @@ DateTime::DateTime(unsigned short hour, unsigned short minute, unsigned short da
this->year = year;
}
-int DateTime::compare(const DateTime& other) {
+int DateTime::compare(const DateTime& other) const {
if (year < other.year || month < other.month || day < other.day || hour < other.hour || minute < other.minute)
return -1;
return year > other.year || month > other.month || day > other.day || hour > other.hour || minute > other.minute;
}
-
-unsigned short DateTime::get_hour() {
+unsigned short DateTime::get_hour() const {
return hour;
}
bool DateTime::set_hour(unsigned short newHour) {
@@ -42,7 +41,7 @@ bool DateTime::set_hour(unsigned short newHour) {
return true;
}
-unsigned short DateTime::get_minute() {
+unsigned short DateTime::get_minute() const {
return minute;
}
bool DateTime::set_minute(unsigned short newMinute) {
@@ -52,7 +51,7 @@ bool DateTime::set_minute(unsigned short newMinute) {
return true;
}
-unsigned short DateTime::get_day() {
+unsigned short DateTime::get_day() const {
return day;
}
bool DateTime::set_day(unsigned short newDay) {
@@ -62,7 +61,7 @@ bool DateTime::set_day(unsigned short newDay) {
return true;
}
-unsigned short DateTime::get_month() {
+unsigned short DateTime::get_month() const {
return month;
}
bool DateTime::set_month(unsigned short newMonth) {
@@ -72,7 +71,7 @@ bool DateTime::set_month(unsigned short newMonth) {
return true;
}
-unsigned short DateTime::get_year() {
+unsigned short DateTime::get_year() const {
return year;
}
bool DateTime::set_year(unsigned short newYear) {
@@ -89,4 +88,8 @@ std::istream& operator>>(std::istream& istr, DateTime& dt) {
return istr;
}
-std::ostream& operator<<(std::ostream& ostr, const DateTime& dt);
+std::ostream& operator<<(std::ostream& ostr, const DateTime& dt) {
+ bool padh = dt.get_hour() < 10, padm = dt.get_minute() < 10;
+ ostr << ((padh) ? "0" : "") << dt.get_hour() << ":" << ((padm) ? "0" : "") << dt.get_minute() << " " << dt.get_day() << "." << dt.get_month() << "." << dt.get_year();
+ return ostr;
+}