Skip to content

calendar.h ~ calendar ~ compare

Baptiste Thémine edited this page Aug 11, 2020 · 1 revision
constexpr int compare(const datetime_type &left, const datetime_type &right) noexcept;
constexpr int compare(const duration_type &left, const duration_type &right) noexcept;

Description

Compares two datetime_type or duration_type.

Parameters

(Mandatory)

  • left
  • rigth

Return value

  • -1 if left is chronologically before right,
  • +1 if left is chronologically after right,
  • 0 if left equals right.

Exceptions

Never throws exception.

Examples

#include <iostream>
#include <JLC/JLC.h>
using namespace JLC;
using typename calendar::datetime_type;

int main(){
    constexpr datetime_type date1 = calendar::make_datetime(1000,1,1);
    constexpr datetime_type date2 = calendar::make_datetime(2000,2,2);
    std::cout << calendar::compare(date1,date2) << std::endl;
    std::cout << calendar::compare(date2,date1) << std::endl;
    std::cout << calendar::compare(date2,date2) << std::endl;
}
-1
1
0

See also

Clone this wiki locally