From c026efd20f57854308364faad2dee7b478754b51 Mon Sep 17 00:00:00 2001 From: aortigos Date: Fri, 24 Apr 2026 13:22:01 +0200 Subject: [PATCH] Fixed check is digit --- ex00/BitcoinExchange/BitcoinExchange.cpp | 8 ++++++++ ex00/input.txt | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) 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