summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Swift/Controllers/HistoryController.cpp5
-rw-r--r--Swift/QtUI/QtHistoryWindow.cpp7
-rw-r--r--Swiften/History/HistoryManager.h3
3 files changed, 12 insertions, 3 deletions
diff --git a/Swift/Controllers/HistoryController.cpp b/Swift/Controllers/HistoryController.cpp
index deda25b..c03cc2c 100644
--- a/Swift/Controllers/HistoryController.cpp
+++ b/Swift/Controllers/HistoryController.cpp
@@ -7,6 +7,7 @@
#include <Swift/Controllers/HistoryController.h>
#include <Swiften/History/SQLiteHistoryManager.h>
#include <Swiften/History/HistoryMessage.h>
+#include <boost/date_time/c_local_time_adjustor.hpp>
namespace Swift {
@@ -20,7 +21,9 @@ HistoryController::~HistoryController() {
}
void HistoryController::addMessage(const std::string& message, const JID& fromJID, const JID& toJID, HistoryMessage::Type type, const boost::posix_time::ptime& timeStamp) {
- HistoryMessage historyMessage(message, fromJID, toJID, type, timeStamp);
+ // note: using localtime timestamps
+ HistoryMessage historyMessage(message, fromJID, toJID, type, boost::date_time::c_local_adjustor<boost::posix_time::ptime>::utc_to_local(timeStamp));
+
localHistory_->addMessage(historyMessage);
onNewMessage(historyMessage);
}
diff --git a/Swift/QtUI/QtHistoryWindow.cpp b/Swift/QtUI/QtHistoryWindow.cpp
index 0a7c5b5..a0ccbf9 100644
--- a/Swift/QtUI/QtHistoryWindow.cpp
+++ b/Swift/QtUI/QtHistoryWindow.cpp
@@ -106,8 +106,11 @@ void QtHistoryWindow::addMessage(const std::string &message, const std::string &
QString messageHTML(P2QSTRING(message));
messageHTML = Qt::escape(messageHTML);
- QDateTime qTime = B2QDATE(time);
- QDate date = qTime.date();
+
+ // note: time uses localtime
+ QDate date = QDate(time.date().year(), time.date().month(), time.date().day());
+ QTime dayTime = QTime(time.time_of_day().hours(), time.time_of_day().minutes(), time.time_of_day().seconds());
+ QDateTime qTime = QDateTime(date, dayTime);
std::string id = "id" + boost::lexical_cast<std::string>(idCounter_++);
diff --git a/Swiften/History/HistoryManager.h b/Swiften/History/HistoryManager.h
index 6b32206..104f0ad 100644
--- a/Swiften/History/HistoryManager.h
+++ b/Swiften/History/HistoryManager.h
@@ -17,6 +17,9 @@ namespace Swift {
typedef std::map<JID, std::set<boost::gregorian::date> > ContactsMap;
class HistoryManager {
+ /**
+ * Messages are stored using localtime timestamps.
+ */
public:
virtual ~HistoryManager();