datetime display fixed for OSs with non-English localization (#3204)
This commit is contained in:
parent
1fbdea0f35
commit
67a2a8cf08
4 changed files with 17 additions and 2 deletions
|
@ -1,6 +1,7 @@
|
|||
#include "logger.h"
|
||||
#include "version_string.h"
|
||||
#include <QDateTime>
|
||||
#include <QLocale>
|
||||
#include <iostream>
|
||||
|
||||
#define LOGGER_MAX_ENTRIES 128
|
||||
|
@ -14,6 +15,7 @@ Logger::Logger() : logToFileEnabled(false)
|
|||
{
|
||||
logBuffer.append(getClientVersion());
|
||||
logBuffer.append(getSystemArchitecture());
|
||||
logBuffer.append(getSystemLocale());
|
||||
std::cerr << getClientVersion().toStdString() << std::endl;
|
||||
std::cerr << getSystemArchitecture().toStdString() << std::endl;
|
||||
}
|
||||
|
@ -106,3 +108,10 @@ QString Logger::getClientOperatingSystem()
|
|||
|
||||
return {};
|
||||
}
|
||||
|
||||
QString Logger::getSystemLocale()
|
||||
{
|
||||
QString result;
|
||||
result.append(tr("System Locale") + ": " + QLocale().name());
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ public:
|
|||
QString getClientVersion();
|
||||
QString getClientOperatingSystem();
|
||||
QString getSystemArchitecture();
|
||||
QString getSystemLocale();
|
||||
QList<QString> getLogBuffer()
|
||||
{
|
||||
return logBuffer;
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#include <QDir>
|
||||
#include <QFile>
|
||||
#include <QLibraryInfo>
|
||||
#include <QLocale>
|
||||
#include <QSystemTrayIcon>
|
||||
#include <QTextCodec>
|
||||
#include <QTextStream>
|
||||
|
@ -69,6 +70,7 @@ void installNewTranslator()
|
|||
qApp->installTranslator(qtTranslator);
|
||||
translator->load(translationPrefix + "_" + lang, translationPath);
|
||||
qApp->installTranslator(translator);
|
||||
qDebug() << "Language changed:" << lang;
|
||||
}
|
||||
|
||||
QString const generateClientID()
|
||||
|
@ -121,6 +123,8 @@ int main(int argc, char *argv[])
|
|||
translator = new QTranslator;
|
||||
installNewTranslator();
|
||||
|
||||
QLocale::setDefault(QLocale::English);
|
||||
|
||||
qsrand(QDateTime::currentDateTime().toTime_t());
|
||||
qDebug("main(): starting main program");
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include <QDateTime>
|
||||
#include <QDebug>
|
||||
#include <QFile>
|
||||
#include <QLocale>
|
||||
#include <QMessageBox>
|
||||
#include <QNetworkReply>
|
||||
#include <QUrl>
|
||||
|
@ -165,11 +166,11 @@ bool SpoilerBackgroundUpdater::saveDownloadedFile(QByteArray data)
|
|||
QList<QByteArray> lines = data.split('\n');
|
||||
|
||||
foreach (QByteArray line, lines) {
|
||||
if (line.indexOf("created:") > -1) {
|
||||
if (line.contains("created:")) {
|
||||
QString timeStamp = QString(line).replace("created:", "").trimmed();
|
||||
timeStamp.chop(6); // Remove " (UTC)"
|
||||
|
||||
auto utcTime = QDateTime::fromString(timeStamp, QString("ddd, MMM dd yyyy, hh:mm:ss"));
|
||||
auto utcTime = QLocale().toDateTime(timeStamp, "ddd, MMM dd yyyy, hh:mm:ss");
|
||||
utcTime.setTimeSpec(Qt::UTC);
|
||||
|
||||
QString localTime = utcTime.toLocalTime().toString("MMM d, hh:mm");
|
||||
|
|
Loading…
Reference in a new issue