From 71e3018e19db2ffa9d80d92c4c33e084737d40f4 Mon Sep 17 00:00:00 2001 From: Kevin Smith <git@kismith.co.uk> Date: Thu, 18 Nov 2010 17:08:51 +0000 Subject: Moving out a convenience function for generating XEP-0082 strings from Boost ptimes 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); }; } -- cgit v0.10.2-6-g49f6