Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[mer] Ensure timestamps use C locale. Contributes to MER#1536
 Timestamps must be generated using the C locale, so they do not contain
 digits other than Latin.
  • Loading branch information
matthewvogt committed Mar 4, 2016
1 parent f8207d4 commit d0158de
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
Expand Up @@ -438,7 +438,7 @@ QString QGeoRoutingManagerEngineNokia::routeRequestString(const QGeoRouteRequest
}

requestString += "&departure=";
requestString += QDateTime::currentDateTime().toUTC().toString("yyyy-MM-ddThh:mm:ssZ");
requestString += QLocale::c().toString(QDateTime::currentDateTime().toUTC(), QStringLiteral("yyyy-MM-ddThh:mm:ssZ"));

requestString += "&instructionformat=text";

Expand Down
3 changes: 2 additions & 1 deletion tests/auto/geotestplugin/qplacemanagerengine_test.h
Expand Up @@ -47,6 +47,7 @@
#include <QtCore/QJsonDocument>
#include <QtCore/QJsonObject>
#include <QtCore/QJsonArray>
#include <QtCore/QLocale>
#include <QtCore/QUuid>
#include <QtPositioning/QGeoCoordinate>
#include <QtPositioning/QGeoLocation>
Expand Down Expand Up @@ -293,7 +294,7 @@ class QPlaceManagerEngineTest : public QPlaceManagerEngine
review.setRating(ro.value("rating").toDouble());

if (ro.contains(QStringLiteral("dateTime")))
review.setDateTime(QDateTime::fromString(
review.setDateTime(QLocale::c().toDateTime(
ro.value(QStringLiteral("dateTime")).toString(),
QLatin1String("hh:mm dd-MM-yyyy")));
if (ro.contains(QStringLiteral("reviewId")))
Expand Down
5 changes: 3 additions & 2 deletions tests/auto/qplacereview/tst_qplacereview.cpp
Expand Up @@ -39,6 +39,7 @@
**
****************************************************************************/

#include <QtCore/QLocale>
#include <QtCore/QString>
#include <QtTest/QtTest>

Expand Down Expand Up @@ -96,8 +97,8 @@ QPlaceReview tst_QPlaceReview::initialSubObject()
review.setText("text");
review.setRating(4.5);
review.setLanguage("en");
review.setDateTime(QDateTime::fromString("01:02 03/04/2000",
"hh:mm dd/MM/yyyy"));
review.setDateTime(QLocale::c().toDateTime("01:02 03/04/2000",
"hh:mm dd/MM/yyyy"));
review.setUser(user);
review.setSupplier(supplier);
review.setAttribution("attribution");
Expand Down
12 changes: 8 additions & 4 deletions tests/auto/utils/qlocationtestutils.cpp
Expand Up @@ -41,6 +41,8 @@

#include "qlocationtestutils_p.h"

#include <QLocale>

bool QLocationTestUtils::hasDefaultSource()
{
return false;
Expand All @@ -66,8 +68,8 @@ QString QLocationTestUtils::addNmeaChecksumAndBreaks(const QString &sentence)

QString QLocationTestUtils::createRmcSentence(const QDateTime &dt)
{
QString time = dt.toString("hhmmss.zzz");
QString date = dt.toString("ddMMyy");
QString time = QLocale::c().toString(dt, QStringLiteral("hhmmss.zzz"));
QString date = QLocale::c().toString(dt, QStringLiteral("ddMMyy"));
QString nmea = QString("$GPRMC,%1,A,2730.83609,S,15301.87844,E,0.7,9.0,%2,11.2,W,A*")
.arg(time).arg(date);
return addNmeaChecksumAndBreaks(nmea);
Expand All @@ -88,8 +90,10 @@ QString QLocationTestUtils::createGgaSentence(int lat, int lng, const QTime &tim

QString QLocationTestUtils::createZdaSentence(const QDateTime &dt)
{
QString time = dt.toString("hhmmss.zzz");
QString nmea = QString("$GPZDA,%1,%2,%3,%4,,*")
.arg(time).arg(dt.toString("dd")).arg(dt.toString("MM")).arg(dt.toString("yyyy"));
.arg(QLocale::c().toString(dt, QStringLiteral("hhmmss.zzz")))
.arg(QLocale::c().toString(dt, QStringLiteral("dd")))
.arg(QLocale::c().toString(dt, QStringLiteral("MM")))
.arg(QLocale::c().toString(dt, QStringLiteral("yyyy")));
return addNmeaChecksumAndBreaks(nmea);
}

0 comments on commit d0158de

Please sign in to comment.