mirror of
https://bitbucket.org/smil3y/kde-extraapps.git
synced 2025-02-23 18:32:53 +00:00
kdeplasma-addons: datetime runner optimization
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
29c60110d3
commit
48ed9841fe
1 changed files with 16 additions and 12 deletions
|
@ -84,21 +84,23 @@ void DateTimeRunner::match(Plasma::RunnerContext &context)
|
||||||
QDateTime DateTimeRunner::datetime(const QString &tz, QString &tzName)
|
QDateTime DateTimeRunner::datetime(const QString &tz, QString &tzName)
|
||||||
{
|
{
|
||||||
QDateTime dt;
|
QDateTime dt;
|
||||||
|
const QDateTime cdt = QDateTime::currentDateTimeUtc();
|
||||||
|
|
||||||
if (tz.compare(QLatin1String("UTC"), Qt::CaseInsensitive) == 0) {
|
if (tz.compare(QLatin1String("UTC"), Qt::CaseInsensitive) == 0) {
|
||||||
tzName = QLatin1String( "UTC" );
|
tzName = QLatin1String( "UTC" );
|
||||||
dt = KTimeZone::utc().toZoneTime(QDateTime::currentDateTimeUtc());
|
dt = cdt;
|
||||||
return dt;
|
return dt;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (const KTimeZone &zone, KSystemTimeZones::zones()) {
|
foreach (const KTimeZone &zone, KSystemTimeZones::zones()) {
|
||||||
const QString zoneName = zone.name();
|
const QString zoneName = zone.name();
|
||||||
const QDateTime zoneDateTime = zone.toZoneTime(QDateTime::currentDateTimeUtc());
|
const QDateTime zoneDateTime = zone.toZoneTime(cdt);
|
||||||
if (zoneName.compare(tz, Qt::CaseInsensitive) == 0) {
|
if (zoneName.compare(tz, Qt::CaseInsensitive) == 0) {
|
||||||
tzName = zoneName;
|
tzName = zoneName;
|
||||||
dt = zoneDateTime;
|
dt = zoneDateTime;
|
||||||
break;
|
break;
|
||||||
} else if (!dt.isValid()) {
|
}
|
||||||
|
|
||||||
if (zoneName.contains(tz, Qt::CaseInsensitive)) {
|
if (zoneName.contains(tz, Qt::CaseInsensitive)) {
|
||||||
tzName = zoneName;
|
tzName = zoneName;
|
||||||
dt = zoneDateTime;
|
dt = zoneDateTime;
|
||||||
|
@ -110,6 +112,8 @@ QDateTime DateTimeRunner::datetime(const QString &tz, QString &tzName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (dt.isValid()) {
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue