Website Summary Files Commits Branches @commit @diff @stats
path: root / src / Generic / Date / Date.cpp
diff options
context:
space:
mode:
Commitda6a5977c238d5e6f30097253dd17b19760934c9 (patch)
Author
 Syndamia <kamen.d.mladenov@protonmail.com>
2022-05-08 09:43:21 +0300
Committer
 Syndamia <kamen.d.mladenov@protonmail.com>
2022-05-08 09:43:21 +0300
Files366d56243f9fecf099f559cb6dda7c1bb31ecdd7 /src/Generic/Date/Date.cpp
FMI-OOP-P1_TicketSystem-da6a5977c238d5e6f30097253dd17b19760934c9.tar
FMI-OOP-P1_TicketSystem-da6a5977c238d5e6f30097253dd17b19760934c9.tar.gz
FMI-OOP-P1_TicketSystem-da6a5977c238d5e6f30097253dd17b19760934c9.zip
Parent72ddedf86f34b28bf5faabf7d1fdd2bf54126164 (diff)
Autocommit at 08.05.2022 @ 09:43
1 files changed, 7 insertions, 12 deletions
-rw-r--r--src/Generic/Date/Date.cpp19
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) {