diff --git a/ex00/BitcoinExchange/BitcoinExchange.cpp b/ex00/BitcoinExchange/BitcoinExchange.cpp index 9d2eb1e..9d0b42d 100644 --- a/ex00/BitcoinExchange/BitcoinExchange.cpp +++ b/ex00/BitcoinExchange/BitcoinExchange.cpp @@ -152,6 +152,14 @@ bool BitcoinExchange::validateDate(const std::string &date) if (date.length() != 10 || date[4] != '-' || date[7] != '-') return (false); + + for (int i = 0; i < 10; i++) + { + if (i == 4 || i == 7) + continue; + if (!isdigit(date[i])) + return (false); + } year = std::atoi(date.substr(0, 4).c_str()); month = std::atoi(date.substr(5, 2).c_str()); diff --git a/ex00/input.txt b/ex00/input.txt index 9d0274a..dda970b 100644 --- a/ex00/input.txt +++ b/ex00/input.txt @@ -1,5 +1,5 @@ date | value -2011-01-03 | 3 +2011-01-a3 | 3 2011-01-03 | 2 2011-01-03 | 1 2011-01-03 | 1.2