Website Summary Files Commits Branches @commit @diff @stats
path: root / src
diff options
context:
space:
mode:
2 files changed, 17 insertions, 0 deletions
-rw-r--r--src/DateTime/DateTime.cpp11
-rw-r--r--src/DateTime/DateTime.h6
diff --git a/src/DateTime/DateTime.cpp b/src/DateTime/DateTime.cpp
index 56ddba1..96e20b3 100644
--- a/src/DateTime/DateTime.cpp
+++ b/src/DateTime/DateTime.cpp
@@ -79,3 +79,14 @@ bool DateTime::set_year(unsigned short newYear) {
year = newYear;
return true;
}
+
+/* Outside of class */
+
+std::istream& operator>>(std::istream& istr, DateTime& dt) {
+ unsigned short h, m, d, M, y;
+ istr >> h >> m >> d >> M >> y;
+ dt = DateTime(h, m, d, M, y);
+ return istr;
+}
+
+std::ostream& operator<<(std::ostream& ostr, const DateTime& dt);
diff --git a/src/DateTime/DateTime.h b/src/DateTime/DateTime.h
index 7faa69c..cab5008 100644
--- a/src/DateTime/DateTime.h
+++ b/src/DateTime/DateTime.h
@@ -1,6 +1,9 @@
#ifndef HEADER_DATETIME
#define HEADER_DATETIME
+#include <istream>
+#include <ostream>
+
class DateTime {
unsigned short hour;
unsigned short minute;
@@ -31,4 +34,7 @@ public:
bool set_year(unsigned short newYear);
};
+std::istream& operator>>(std::istream& istr, DateTime& dt);
+std::ostream& operator<<(std::ostream& ostr, const DateTime& dt);
+
#endif