#include "ProcessHistory.h" #include "X3DBaseTypes.h" #include "X3D_Scene.h" #include using namespace std; namespace X3DTK { ProcessHistory::ProcessHistory() { } ProcessHistory::ProcessHistory(const ProcessHistory &H) : _processMap(H._processMap) { } void ProcessHistory::addEntry(const SFString &content, const struct tm &time) { SFString date; MFString st; st.push_back(SFString::number(time.tm_mon + 1)); st.push_back(SFString::number(time.tm_mday + 1)); st.push_back(SFString::number(time.tm_year + 1900)); st.push_back(SFString::number(time.tm_hour)); st.push_back(SFString::number(time.tm_min)); st.push_back(SFString::number(time.tm_sec)); for (MFString::iterator it = st.begin(); it != st.end(); ++it) { if ((*it).size() == 1) *it = "0" + *it; } date += st[0] + "-" + st[1] + "-" + st[2]; date += " " + st[3] + ":" + st[4] + ":" + st[5]; _processMap.push_back(std::pair(content, date)); } void ProcessHistory::addEntry(const SFString &content) { time_t rawtime; struct tm *timeInfo; time(&rawtime); timeInfo = localtime(&rawtime); addEntry(content, *timeInfo); } struct tm ProcessHistory::loadTime(const SFString &date) { cout << "loading time" << endl; SFString mon = date.substr(0, 2); SFString day = date.substr(3, 2); SFString year = date.substr(6, 4); SFString hour = date.substr(11, 2); SFString min = date.substr(14, 2); SFString sec = date.substr(17, 2); cout << "mon = " << mon << endl; cout << "day = " << day << endl; cout << "year = " << year << endl; cout << "hour = " << hour << endl; cout << "min = " << min << endl; cout << "sec = " << sec << endl; struct tm time; time.tm_mon = mon.toInt() - 1; time.tm_mday = day.toInt() - 1; time.tm_year = year.toInt() - 1900; time.tm_hour = hour.toInt(); time.tm_min = min.toInt(); time.tm_sec = sec.toInt(); return time; } void ProcessHistory::loadScene(X3D::Scene *S, const ProcessHistory &history) { S->setProcessHistory(history); } }