+ import std.math; import std.typecons; - import std.math; /* You have to write a function which validates a given date string and - returns true if the date is valid otherwise false. ? ---- + returns true if the date is valid otherwise false. - The date is valid if all of the following rules are satisfied: ? ---- + The date is valid if all of the following rules are satisfied: - 1. The date string is not empty. ? ---- + 1. The date string is not empty. - 2. The number of days is not less than 1 or higher than 31 days for months 1,3,5,7,8,10,12. And the number of days is not less than 1 or higher than 30 days for months 4,6,9,11. And, the number of days is not less than 1 or higher than 29 for the month 2. ? ---- + 2. The number of days is not less than 1 or higher than 31 days for months 1,3,5,7,8,10,12. And the number of days is not less than 1 or higher than 30 days for months 4,6,9,11. And, the number of days is not less than 1 or higher than 29 for the month 2. - 3. The months should not be less than 1 or higher than 12. ? ---- + 3. The months should not be less than 1 or higher than 12. - 4. The date should be in the format: mm-dd-yyyy ? ---- + 4. The date should be in the format: mm-dd-yyyy - - >>> valid_date("03-11-2000") ? ---- + >>> valid_date("03-11-2000") + true - true - - >>> valid_date("15-01-2012") ? ---- + >>> valid_date("15-01-2012") + false - false - - >>> valid_date("04-0-2040") ? ---- + >>> valid_date("04-0-2040") + false - false - - >>> valid_date("06-04-2020") ? ---- + >>> valid_date("06-04-2020") + true - true - - >>> valid_date("06/04/2020") ? ---- + >>> valid_date("06/04/2020") + false - false - */ bool valid_date(string date)