-
Notifications
You must be signed in to change notification settings - Fork 0
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;
Compares two datetime_type or duration_type.
(Mandatory)
left
rigth
-
-1
ifleft
is chronologically beforeright
, -
+1
ifleft
is chronologically afterright
, -
0
ifleft
equalsright
.
Never throws exception.
#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