Commit 12ba18aa authored by David Jarvie's avatar David Jarvie
Browse files

Use QLocale::toString() instead of QTime::toString()

Qt6 will use C locale for QTime::toString()
parent aaf3dd20
......@@ -419,8 +419,9 @@ QString MessageDisplayHelper::dateTimeToDisplay() const
QString tm;
if (mDateTime.isValid())
{
QLocale locale;
if (mDateTime.isDateOnly())
tm = QLocale().toString(mDateTime.date(), QLocale::ShortFormat);
tm = locale.toString(mDateTime.date(), QLocale::ShortFormat);
else
{
bool showZone = false;
......@@ -437,9 +438,9 @@ QString MessageDisplayHelper::dateTimeToDisplay() const
showZone = (local.toString(QStringLiteral("%Z")) != tz);
}
const QDateTime dt = mDateTime.qDateTime();
tm = QLocale().toString(dt, QLocale::ShortFormat);
tm = locale.toString(dt, QLocale::ShortFormat);
if (showZone)
tm += QLatin1Char(' ') + mDateTime.timeZone().displayName(dt, QTimeZone::ShortName, QLocale());
tm += QLatin1Char(' ') + mDateTime.timeZone().displayName(dt, QTimeZone::ShortName, locale);
}
}
return tm;
......
......@@ -660,6 +660,7 @@ QString ResourceDataModelBase::alarmTimeText(const DateTime& dateTime, char lead
if (!dateTime.isValid())
return i18nc("@info Alarm never occurs", "Never");
QLocale locale;
if (!leadingZeroesChecked)
{
// Check whether the day number and/or hour have no leading zeroes, if
......@@ -671,7 +672,6 @@ QString ResourceDataModelBase::alarmTimeText(const DateTime& dateTime, char lead
// Check the date format. 'dd' provides leading zeroes; single 'd'
// provides no leading zeroes.
QLocale locale;
dateFormat = locale.dateFormat(QLocale::ShortFormat);
// Check the time format.
......@@ -724,8 +724,8 @@ QString ResourceDataModelBase::alarmTimeText(const DateTime& dateTime, char lead
timeFullFormat.insert(i, timeFormat.at(i));
// Find index to hour in formatted times
const QTime t(1,30,30);
const QString nozero = t.toString(timeFormat);
const QString zero = t.toString(timeFullFormat);
const QString nozero = locale.toString(t, timeFormat);
const QString zero = locale.toString(t, timeFullFormat);
for (int i = 0; i < nozero.size(); ++i)
if (nozero[i] != zero[i])
{
......@@ -737,7 +737,6 @@ QString ResourceDataModelBase::alarmTimeText(const DateTime& dateTime, char lead
leadingZeroesChecked = true;
}
QLocale locale;
const KADateTime kdt = dateTime.effectiveKDateTime().toTimeSpec(Preferences::timeSpec());
QString dateTimeText = locale.toString(kdt.date(), dateFormat);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment