From da6a5977c238d5e6f30097253dd17b19760934c9 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sun, 8 May 2022 09:43:21 +0300 Subject: Autocommit at 08.05.2022 @ 09:43 --- src/Generic/Date/Date.cpp | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'src/Generic/Date/Date.cpp') diff --git a/src/Generic/Date/Date.cpp b/src/Generic/Date/Date.cpp index 45996dc..831c532 100644 --- a/src/Generic/Date/Date.cpp +++ b/src/Generic/Date/Date.cpp @@ -19,18 +19,13 @@ unsigned short Date::daysInMonth() { Date::Date() : Date(01, 05, 2022) {} -Date::Date(const char* str) : Date(0, 0, 0) { - for (unsigned i = 0; str[i] != '\0' && year == 0; i++) { - if (str[i] != ' ') { - unsigned temp = atoi(str + i); - if (temp == 0) return; // can only happen with incorrect input - - if (day == 0) day = temp; - else if (month == 0) month = temp; - else year = temp; - i++; - } - } +Date::Date(const char* str) { + while (*str == ' ' && *str != '\0') str++; + day = atoi(str); + while (*str == ' ' && *str != '\0') str++; + month = atoi(str); + while (*str == ' ' && *str != '\0') str++; + year = atoi(str); } Date::Date(unsigned short day, unsigned short month, unsigned short year) { -- cgit v1.3.1-26-gb76a