Skip to content

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;

Description

Returns true if the specified time representation is valid ISO 8601.

Requirements

<cstring> enables the character sequence function.

Parameters

(Mandatory)

  • hour --> Hour
  • min --> Minute
  • sec --> Second
  • milli --> Millisecond
  • str --> String representation of a time

Return value

If the specified time is valid ISO 8601, then returns true, else returns false.

Exceptions

Never throws exception.

Examples

#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

See also

Clone this wiki locally