diff options
Autocommit at 07.05.2022 @ 17:08
2 files changed, 22 insertions, 6 deletions
| -rw-r--r-- | src/Generic/Date/Date.cpp | 25 | ||||
| -rw-r--r-- | src/Generic/Date/Date.h | 3 |
diff --git a/src/Generic/Date/Date.cpp b/src/Generic/Date/Date.cpp index 3df7947..b9f24d3 100644 --- a/src/Generic/Date/Date.cpp +++ b/src/Generic/Date/Date.cpp @@ -25,12 +25,6 @@ Date::Date(unsigned short day, unsigned short month, unsigned short year) { this->year = year; } -int Date::compare(const Date& other) const { - if (year < other.year || month < other.month || day < other.day) - return -1; - return year > other.year || month > other.month || day > other.day; -} - unsigned short Date::get_day() const { return day; } @@ -60,6 +54,25 @@ bool Date::set_year(unsigned short newYear) { return true; } +void Date::read(std::istream& istr) { + istr.read((char*)&day, sizeof(day)); + istr.read((char*)&month, sizeof(month)); + istr.read((char*)&year, sizeof(year)); +} + +void Date::write(std::ostream& ostr) { + ostr.write((char*)&day, sizeof(day)); + ostr.write((char*)&month, sizeof(month)); + ostr.write((char*)&year, sizeof(year)); +} + +int Date::compare(const Date& other) const { + if (year < other.year || month < other.month || day < other.day) + return -1; + return year > other.year || month > other.month || day > other.day; +} + + /* Outside of class */ std::istream& operator>>(std::istream& istr, Date& dt) { diff --git a/src/Generic/Date/Date.h b/src/Generic/Date/Date.h index aa4047d..f8d5e21 100644 --- a/src/Generic/Date/Date.h +++ b/src/Generic/Date/Date.h @@ -17,8 +17,11 @@ public: Date(unsigned short day, unsigned short month, unsigned short year); unsigned short get_day() const; + bool set_day(unsigned short day); unsigned short get_month() const; + bool set_month(unsigned short month); unsigned short get_year() const; + bool set_year(unsigned short year); void read(std::istream& istr); void write(std::ostream& ostr); |
