diff options
Autocommit at 08.05.2022 @ 09:33
2 files changed, 12 insertions, 0 deletions
| -rw-r--r-- | src/Generic/Date/Date.cpp | 11 | ||||
| -rw-r--r-- | src/Generic/Date/Date.h | 1 |
diff --git a/src/Generic/Date/Date.cpp b/src/Generic/Date/Date.cpp index b9f24d3..4961698 100644 --- a/src/Generic/Date/Date.cpp +++ b/src/Generic/Date/Date.cpp @@ -19,6 +19,17 @@ unsigned short Date::daysInMonth() { Date::Date() : Date(01, 05, 2022) {} +Date::Date(const char* str) : Date(0, 0, 0) { + for (unsigned i = 0; i < MAX_LINE_WIDTH && y == 0; i++) { + if (dateStr[i] != ' ') { + if (d == 0) d = atoi(dateStr + i); + else if (m == 0) m = atoi(dateStr + i); + else y = atoi(dateStr + i); + i++; + } + } +} + Date::Date(unsigned short day, unsigned short month, unsigned short year) { this->day = day; this->month = month; diff --git a/src/Generic/Date/Date.h b/src/Generic/Date/Date.h index f8d5e21..a7c0ecb 100644 --- a/src/Generic/Date/Date.h +++ b/src/Generic/Date/Date.h @@ -14,6 +14,7 @@ class Date { public: Date(); + Date(const char* str); Date(unsigned short day, unsigned short month, unsigned short year); unsigned short get_day() const; |
