/*
@endTime 格式:2016-02-23 00:00:00
@startTime 格式:2016-02-23 00:00:00
*/
double calculateTime(const std::string& endTime, const std::string& startTime)
{
tm tm_s;
time_t start;
strptime(startTime.c_str(), "%Y-%m-%d %H:%M:%S", &tm_s);
start = mktime(&tm_s);
tm tm_e;
time_t end;
strptime(endTime.c_str(), "%Y-%m-%d %H:%M:%S", &tm_e);
end = mktime(&tm_e);
double result = std::difftime(end, start);
return result;
}
@endTime 格式:2016-02-23 00:00:00
@startTime 格式:2016-02-23 00:00:00
*/
double calculateTime(const std::string& endTime, const std::string& startTime)
{
tm tm_s;
time_t start;
strptime(startTime.c_str(), "%Y-%m-%d %H:%M:%S", &tm_s);
start = mktime(&tm_s);
tm tm_e;
time_t end;
strptime(endTime.c_str(), "%Y-%m-%d %H:%M:%S", &tm_e);
end = mktime(&tm_e);
double result = std::difftime(end, start);
return result;
}