Is there such a type as "days"?
Printable View
Is there such a type as "days"?
Yep! Got it to compile now... One issue though, Is this function accurate? I mean should return_days calculation consider hours and minutes as well?
[EDIT}Code:void Contract::CalculateNoOfDays(Date issue_dt, Date return_dt)
{
using namespace boost::gregorian;
std::ostringstream issue_dymonyr, return_dymonyr;
issue_dymonyr << issue_dt.getMonth() << "-" << issue_dt.getDay() << "-" << issue_dt.getYear();
return_dymonyr << return_dt.getMonth() << "-" << return_dt.getDay() << "-" << return_dt.getYear();
try {
date issuedDate(from_simple_string(issue_dymonyr.str()));
date returnDate(from_simple_string(return_dymonyr.str()));
days rental_days = returnDate - issuedDate;
}
catch(...) {
std::cout << "Bad date entered: " << issue_dymonyr.str() << return_dymonyr.str() << std::endl;
}
}
Not forgetting how to convert from days to a normal integer value [/EDIT]
Maybe you want to take a look at the examples?
http://www.boost.org/doc/libs/1_37_0...te_period_calc
They might give you some insight. Be sure to consult the documentation for the classes, as well. There might be something there.
I am not familiar with Boost::DateTime, however, so I cannot say.