From f54d65ca86f9eaf5bc8596beba1067948036d358 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Netto?= Date: Tue, 13 Aug 2019 10:32:39 -0300 Subject: [PATCH] Changed util.printd to work with the default locale set on QLocale::setDefault to allow consistent results in tests --- autotests/formattest.cpp | 4 ++++ core/script/kjs_util.cpp | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/autotests/formattest.cpp b/autotests/formattest.cpp index 525f24abd..4875d23d7 100644 --- a/autotests/formattest.cpp +++ b/autotests/formattest.cpp @@ -41,6 +41,10 @@ void FormatTest::initTestCase() Okular::SettingsCore::instance( QStringLiteral( "formattest" ) ); m_document = new Okular::Document( nullptr ); + // Force consistent locale + QLocale locale( QStringLiteral( "en_US" ) ); + QLocale::setDefault( locale ); + const QString testFile = QStringLiteral( KDESRCDIR "data/formattest.pdf" ); QMimeDatabase db; const QMimeType mime = db.mimeTypeForFile( testFile ); diff --git a/core/script/kjs_util.cpp b/core/script/kjs_util.cpp index 701a1dbc4..42782c726 100644 --- a/core/script/kjs_util.cpp +++ b/core/script/kjs_util.cpp @@ -107,7 +107,9 @@ static KJSObject printd( KJSContext *context, void *, arg( str[2] ).arg( str[3] ).arg( str[4] ).arg( str[5] ).arg( str[6] ); QDateTime date = locale.toDateTime( myStr, QStringLiteral( "MMM/d/yyyy H:m:s" ) ); - return KJSString( date.toString( format ) ); + QLocale defaultLocale; + + return KJSString( defaultLocale.toString( date, format ) ); } void JSUtil::initType( KJSContext *ctx )