Skip to content

Commit

Permalink
Convert some the code in [d4f718c] Myth Services UTC commit, to use M…
Browse files Browse the repository at this point in the history
…ythDate utility functions.

Note the code as is will work so there is no need to update immediately if you are working with the services API.
  • Loading branch information
daniel-kristjansson committed Jun 21, 2012
1 parent 4c37533 commit f2dd6f9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
5 changes: 2 additions & 3 deletions mythtv/libs/libmythservicecontracts/service.cpp
Expand Up @@ -11,6 +11,7 @@
//////////////////////////////////////////////////////////////////////////////

#include "service.h"
#include "mythdate.h"

//////////////////////////////////////////////////////////////////////////////
//
Expand Down Expand Up @@ -75,9 +76,7 @@ void* Service::ConvertToParameterPtr( int nTypeId,

case QMetaType::QDateTime :
{
QDateTime dt = QDateTime::fromString( sValue, Qt::ISODate );
dt.setTimeSpec(Qt::UTC);
*(( QDateTime *)pParam) = dt.toLocalTime();
*(( QDateTime *)pParam) = MythDate::fromString( sValue );
break;
}
case QMetaType::QTime : *(( QTime *)pParam) = QTime::fromString ( sValue, Qt::ISODate ); break;
Expand Down
7 changes: 4 additions & 3 deletions mythtv/libs/libmythupnp/serializers/jsonSerializer.cpp
Expand Up @@ -11,10 +11,10 @@
//////////////////////////////////////////////////////////////////////////////

#include "jsonSerializer.h"
#include "mythdate.h"

#include <QTextCodec>
#include <QVariant>
#include <QDateTime>

//////////////////////////////////////////////////////////////////////////////
//
Expand Down Expand Up @@ -147,8 +147,9 @@ void JSONSerializer::RenderValue( const QVariant &vValue )
case QVariant::Map: RenderMap ( vValue.toMap() ); break;
case QVariant::DateTime:
{
m_Stream << "\"" << Encode( vValue.toDateTime().toUTC()
.toString(Qt::ISODate) ) << "\"";
m_Stream << "\"" << Encode(
MythDate::toString( vValue.toDateTime(), MythDate::ISODate ) )
<< "\"";
break;
}
default:
Expand Down
8 changes: 5 additions & 3 deletions mythtv/libs/libmythupnp/serializers/xmlSerializer.cpp
Expand Up @@ -11,9 +11,9 @@
//////////////////////////////////////////////////////////////////////////////

#include "xmlSerializer.h"
#include "mythdate.h"

#include <QMetaClassInfo>
#include <QDateTime>

// --------------------------------------------------------------------------
// This version should be bumped if the serializer code is changed in a way
Expand Down Expand Up @@ -173,7 +173,9 @@ void XmlSerializer::RenderValue( const QString &sName, const QVariant &vValue )
if (dt.isNull())
m_pXmlWriter->writeAttribute( "xsi:nil", "true" );

m_pXmlWriter->writeCharacters( dt.toUTC().toString(Qt::ISODate) );
m_pXmlWriter->writeCharacters(
MythDate::toString( dt, MythDate::ISODate ) );

break;
}

Expand Down Expand Up @@ -333,4 +335,4 @@ QString XmlSerializer::FindOptionValue( const QStringList &sOptions, const QStri
}

return QString();
}
}

0 comments on commit f2dd6f9

Please sign in to comment.