From 63de60dac600542823843223ee091ace86725361 Mon Sep 17 00:00:00 2001 From: Jeremy Lainé Date: Mon, 8 Nov 2010 09:26:45 +0000 Subject: QXmppEntityTimeIq should store timezone offsets in seconds and handle parsing / serialisation internally. --- src/QXmppEntityTimeIq.cpp | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'src/QXmppEntityTimeIq.cpp') diff --git a/src/QXmppEntityTimeIq.cpp b/src/QXmppEntityTimeIq.cpp index d86579aa..7a90f64c 100644 --- a/src/QXmppEntityTimeIq.cpp +++ b/src/QXmppEntityTimeIq.cpp @@ -29,21 +29,35 @@ #include "QXmppConstants.h" #include "QXmppUtils.h" -QString QXmppEntityTimeIq::tzo() const +/// Returns the timezone offset in seconds. +/// + +int QXmppEntityTimeIq::tzo() const { return m_tzo; } -void QXmppEntityTimeIq::setTzo(const QString &tzo) +/// Sets the timezone offset in seconds. +/// +/// \param tzo + +void QXmppEntityTimeIq::setTzo(int tzo) { m_tzo = tzo; } +/// Returns the date/time in Coordinated Universal Time (UTC). +/// + QDateTime QXmppEntityTimeIq::utc() const { return m_utc; } +/// Sets the date/time in Coordinated Universal Time (UTC). +/// +/// \param utc + void QXmppEntityTimeIq::setUtc(const QDateTime &utc) { m_utc = utc; @@ -58,7 +72,7 @@ bool QXmppEntityTimeIq::isEntityTimeIq(const QDomElement &element) void QXmppEntityTimeIq::parseElementFromChild(const QDomElement &element) { QDomElement timeElement = element.firstChildElement("time"); - m_tzo = timeElement.firstChildElement("tzo").text(); + m_tzo = timezoneOffsetFromString(timeElement.firstChildElement("tzo").text()); m_utc = datetimeFromString(timeElement.firstChildElement("utc").text()); } @@ -67,8 +81,7 @@ void QXmppEntityTimeIq::toXmlElementFromChild(QXmlStreamWriter *writer) const writer->writeStartElement("time"); helperToXmlAddAttribute(writer, "xmlns", ns_entity_time); - if(!m_tzo.isEmpty()) - helperToXmlAddTextElement(writer, "tzo", m_tzo); + helperToXmlAddTextElement(writer, "tzo", timezoneOffsetToString(m_tzo)); if(m_utc.isValid()) helperToXmlAddTextElement(writer, "utc", datetimeToString(m_utc)); -- cgit v1.2.3