c++ - cannot convert »boost::gregorian::date_duration« to »int -
i using boost libs , work int :
but receiving error :
cannot convert »boost::gregorian::date_duration« »int what ? please help, want check if date passed current date.. right answer not work with. (range.length())
#include <iostream> #include <boost/date_time/gregorian/gregorian.hpp> #include <ctime> #include <fstream> namespace bdt = boost::gregorian; using namespace std; int main(void) { time_t = time(0); tm *ltm = localtime(&now); //aktuelles datum int y = 1900 + ltm->tm_year; int d = ltm->tm_mday; int m = 1 + ltm->tm_mon; bdt::date today(bdt::date(y, m, d)); //ziel y m d bdt::date electionday(bdt::date(2012, 6, 6)); bdt::date_period range(today, electionday); std::cout << range.length() << std::endl; int z = range.length() ; return 0; }
assuming want integer represent number of days in period, then:
range.length().days() or, if want compare dates, can without converting periods, durations, integers, or else:
if (today > electionday) { std::cout << "election day in past\n"; }
Comments
Post a Comment