From 9d90246b0e6e6cb7c98f47b87d2629509f106263 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sat, 7 May 2022 17:08:58 +0300 Subject: Autocommit at 07.05.2022 @ 17:08 --- src/Generic/Date/Date.cpp | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) (limited to 'src/Generic/Date/Date.cpp') 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) { -- cgit v1.3.1-23-gd82d