Skip to content

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;

Description

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

Requirements

<cstring> enables the character sequence function.

Parameters

(Mandatory)

  • year --> Year
  • month --> Month
  • day --> Day of month
  • str --> String representation of a date

Return value

If the specified date 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_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

See also

Clone this wiki locally