C++ Boost Datetime

Da Andreabont's Wiki.

La libreria Boost Datetime permette di manipolare le date.

Codice

#include <iostream>
#include <boost/date_time/gregorian/gregorian.hpp>

int main() {

    boost::gregorian::date d1(2019, boost::date_time::Jan, 12);    
    boost::gregorian::date d2 = boost::gregorian::from_string("2019/01/01") + boost::gregorian::date_duration(11);
    
    std::cout << d1 << " == " << d2 << " = " << std::boolalpha << (d1==d2) << std::endl;
    
}

Compilare

g++ -std=c++17 main.cpp -lboost_date_time