-
Notifications
You must be signed in to change notification settings - Fork 0
calendar.h ~ calendar ~ is_time
Baptiste Thémine edited this page Aug 6, 2020
·
2 revisions
constexpr bool is_time(int hour, int min, int sec, int milli) noexcept;
bool is_time(const char *str) noexcept;
Returns true if the specified time representation is valid ISO 8601.
<cstring>
enables the character sequence function.
(Mandatory)
-
hour
--> Hour -
min
--> Minute -
sec
--> Second -
milli
--> Millisecond -
str
--> String representation of a time
If the specified time 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_time(-1,-2,-3,-4) << std::endl;
std::cout << calendar::is_time(24,0,0,0) << std::endl;
std::cout << calendar::is_time(12,60,0,0) << std::endl;
std::cout << calendar::is_time(12,34,60,0) << std::endl;
std::cout << calendar::is_time(12,34,56,1000) << std::endl;
std::cout << calendar::is_time(12,34,56,789) << std::endl;
std::cout << calendar::is_time("T24:00") << std::endl;
std::cout << calendar::is_time("T12:60") << std::endl;
std::cout << calendar::is_time("T12:34") << std::endl;
std::cout << calendar::is_time("T12:34:56") << std::endl;
std::cout << calendar::is_time("T12:34:56.789") << std::endl;
}
false
false
false
false
false
true
false
false
true
true
true