summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2010-11-18 17:08:51 (GMT)
committerKevin Smith <git@kismith.co.uk>2010-11-18 17:08:51 (GMT)
commit71e3018e19db2ffa9d80d92c4c33e084737d40f4 (patch)
tree20178380d469f3c193260365042ce2cdbc04ed89 /Swiften
parent0c3b6522c72a63fc7cee12e8412512cd2e9ae3bd (diff)
downloadswift-contrib-71e3018e19db2ffa9d80d92c4c33e084737d40f4.zip
swift-contrib-71e3018e19db2ffa9d80d92c4c33e084737d40f4.tar.bz2
Moving out a convenience function for generating XEP-0082 strings from Boost ptimes
Diffstat (limited to 'Swiften')
-rw-r--r--Swiften/Serializer/PayloadSerializers/DelaySerializer.cpp11
-rw-r--r--Swiften/Serializer/PayloadSerializers/DelaySerializer.h1
2 files changed, 9 insertions, 3 deletions
diff --git a/Swiften/Serializer/PayloadSerializers/DelaySerializer.cpp b/Swiften/Serializer/PayloadSerializers/DelaySerializer.cpp
index 041165f..a54cf9e 100644
--- a/Swiften/Serializer/PayloadSerializers/DelaySerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/DelaySerializer.cpp
@@ -20,11 +20,16 @@ String DelaySerializer::serializePayload(boost::shared_ptr<Delay> delay) const
if (delay->getFrom()) {
delayElement.setAttribute("from", delay->getFrom()->toString());
}
- String stampString = String(boost::posix_time::to_iso_extended_string(delay->getStamp()));
- stampString.replaceAll(',', ".");
- stampString += "Z";
+ String stampString = boostPTimeToXEP0082(delay->getStamp());
delayElement.setAttribute("stamp", stampString);
return delayElement.serialize();
}
+String DelaySerializer::boostPTimeToXEP0082(const boost::posix_time::ptime& time) {
+ String stampString = String(boost::posix_time::to_iso_extended_string(time));
+ stampString.replaceAll(',', ".");
+ stampString += "Z";
+ return stampString;
+}
+
}
diff --git a/Swiften/Serializer/PayloadSerializers/DelaySerializer.h b/Swiften/Serializer/PayloadSerializers/DelaySerializer.h
index 949b084..eb33c9f 100644
--- a/Swiften/Serializer/PayloadSerializers/DelaySerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/DelaySerializer.h
@@ -15,6 +15,7 @@ namespace Swift {
DelaySerializer();
virtual String serializePayload(boost::shared_ptr<Delay>) const;
+ static String boostPTimeToXEP0082(const boost::posix_time::ptime& time);
};
}