summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Swift/Controllers/Chat/ChatController.cpp5
-rw-r--r--Swift/Controllers/Roster/ContactRosterItem.cpp3
-rw-r--r--Swiften/Base/DateTime.cpp5
-rw-r--r--Swiften/Base/DateTime.h5
4 files changed, 15 insertions, 3 deletions
diff --git a/Swift/Controllers/Chat/ChatController.cpp b/Swift/Controllers/Chat/ChatController.cpp
index 2d2d941..3c0e933 100644
--- a/Swift/Controllers/Chat/ChatController.cpp
+++ b/Swift/Controllers/Chat/ChatController.cpp
@@ -24,6 +24,7 @@
#include <Swift/Controllers/StatusUtil.h>
#include <Swiften/Disco/EntityCapsProvider.h>
#include <Swiften/Base/foreach.h>
+#include <Swiften/Base/DateTime.h>
#include <Swift/Controllers/UIEvents/UIEventStream.h>
#include <Swift/Controllers/UIEvents/SendFileUIEvent.h>
#include <Swift/Controllers/UIEvents/AcceptWhiteboardSessionUIEvent.h>
@@ -65,7 +66,7 @@ ChatController::ChatController(const JID& self, StanzaChannel* stanzaChannel, IQ
}
Idle::ref idle;
if (theirPresence && (idle = theirPresence->getPayload<Idle>())) {
- startMessage += QT_TRANSLATE_NOOP("", ", who has been idle since ") + boost::posix_time::to_simple_string(idle->getSince());
+ startMessage += str(format(QT_TRANSLATE_NOOP("", ", who has been idle since %1%")) % dateTimeToLocalString(idle->getSince()));
}
startMessage += ": " + statusShowTypeToFriendlyName(theirPresence ? theirPresence->getShow() : StatusShow::None);
if (theirPresence && !theirPresence->getStatus().empty()) {
@@ -342,7 +343,7 @@ std::string ChatController::getStatusChangeString(boost::shared_ptr<Presence> pr
}
Idle::ref idle;
if ((idle = presence->getPayload<Idle>())) {
- response += QT_TRANSLATE_NOOP("", " and has been idle since ") + boost::posix_time::to_simple_string(idle->getSince());
+ response += str(format(QT_TRANSLATE_NOOP("", " and has been idle since %1%")) % dateTimeToLocalString(idle->getSince()));
}
if (!response.empty()) {
diff --git a/Swift/Controllers/Roster/ContactRosterItem.cpp b/Swift/Controllers/Roster/ContactRosterItem.cpp
index d2edfe7..f301552 100644
--- a/Swift/Controllers/Roster/ContactRosterItem.cpp
+++ b/Swift/Controllers/Roster/ContactRosterItem.cpp
@@ -8,6 +8,7 @@
#include "Swift/Controllers/Roster/GroupRosterItem.h"
#include <Swiften/Base/foreach.h>
+#include <Swiften/Base/DateTime.h>
#include <Swiften/Elements/Idle.h>
#include <boost/date_time/posix_time/posix_time.hpp>
@@ -47,7 +48,7 @@ std::string ContactRosterItem::getIdleText() const {
if (!idle || idle->getSince().is_not_a_date_time()) {
return "";
} else {
- return boost::posix_time::to_simple_string(idle->getSince());
+ return dateTimeToLocalString(idle->getSince());
}
}
diff --git a/Swiften/Base/DateTime.cpp b/Swiften/Base/DateTime.cpp
index fae26d4..5d192c4 100644
--- a/Swiften/Base/DateTime.cpp
+++ b/Swiften/Base/DateTime.cpp
@@ -10,6 +10,7 @@
#include <boost/date_time/time_facet.hpp>
#include <boost/date_time/local_time/local_time.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
+#include <boost/date_time/c_local_time_adjustor.hpp>
#include <Swiften/Base/String.h>
@@ -31,4 +32,8 @@ std::string dateTimeToString(const boost::posix_time::ptime& time) {
return stampString;
}
+std::string dateTimeToLocalString(const boost::posix_time::ptime& time) {
+ return boost::posix_time::to_simple_string(boost::date_time::c_local_adjustor<boost::posix_time::ptime>::utc_to_local(time));
+}
+
}
diff --git a/Swiften/Base/DateTime.h b/Swiften/Base/DateTime.h
index bc9eecb..891b170 100644
--- a/Swiften/Base/DateTime.h
+++ b/Swiften/Base/DateTime.h
@@ -20,4 +20,9 @@ namespace Swift {
* Converts a UTC ptime object to a XEP-0082 formatted string.
*/
SWIFTEN_API std::string dateTimeToString(const boost::posix_time::ptime& time);
+
+ /**
+ * Converts a UTC ptime object to a localized human readable string.
+ */
+ SWIFTEN_API std::string dateTimeToLocalString(const boost::posix_time::ptime& time);
}