-
Notifications
You must be signed in to change notification settings - Fork 0
calendar.h ~ calendar ~ is_date
Baptiste Thémine edited this page Aug 6, 2020
·
3 revisions
constexpr bool is_date(int year, int month, int day) noexcept;
bool is_date(const char *str) noexcept;
Returns true if the specified date representation is valid ISO 8601.
<cstring>
enables the character sequence function.
(Mandatory)
-
year
--> Year -
month
--> Month -
day
--> Day of month -
str
--> String representation of a date
If the specified date is valid ISO 8601, then returns true, else returns false.
Never throws exception.
#include <iostream>
#include <JLC/JLC.h>
using namespace JLC;
int main(){
std::cout << std::boolalpha;
std::cout << calendar::is_date(0,0,0) << std::endl;
std::cout << calendar::is_date(-1,-2,-3) << std::endl;
std::cout << calendar::is_date(2012,13,1) << std::endl;
std::cout << calendar::is_date(2012,12,32) << std::endl;
std::cout << calendar::is_date(2012,12,21) << std::endl;
std::cout << calendar::is_date("0000-00-00") << std::endl;
std::cout << calendar::is_date("2012-13-01") << std::endl;
std::cout << calendar::is_date("2012-12-32") << std::endl;
std::cout << calendar::is_date("2012-12-21") << std::endl;
}
false
false
false
false
true
false
false
false
true