mirror of
https://bitbucket.org/smil3y/kde-extraapps.git
synced 2025-02-23 10:22:52 +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,33 +84,37 @@ void DateTimeRunner::match(Plasma::RunnerContext &context)
|
|||
QDateTime DateTimeRunner::datetime(const QString &tz, QString &tzName)
|
||||
{
|
||||
QDateTime dt;
|
||||
const QDateTime cdt = QDateTime::currentDateTimeUtc();
|
||||
|
||||
if (tz.compare(QLatin1String("UTC"), Qt::CaseInsensitive) == 0) {
|
||||
tzName = QLatin1String( "UTC" );
|
||||
dt = KTimeZone::utc().toZoneTime(QDateTime::currentDateTimeUtc());
|
||||
dt = cdt;
|
||||
return dt;
|
||||
}
|
||||
|
||||
foreach (const KTimeZone &zone, KSystemTimeZones::zones()) {
|
||||
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) {
|
||||
tzName = zoneName;
|
||||
dt = zoneDateTime;
|
||||
break;
|
||||
} else if (!dt.isValid()) {
|
||||
if (zoneName.contains(tz, Qt::CaseInsensitive)) {
|
||||
tzName = zoneName;
|
||||
dt = zoneDateTime;
|
||||
} else {
|
||||
foreach (const QByteArray &abbrev, zone.abbreviations()) {
|
||||
if (QString(abbrev).contains(tz, Qt::CaseInsensitive)) {
|
||||
tzName = abbrev;
|
||||
dt = zoneDateTime;
|
||||
}
|
||||
}
|
||||
|
||||
if (zoneName.contains(tz, Qt::CaseInsensitive)) {
|
||||
tzName = zoneName;
|
||||
dt = zoneDateTime;
|
||||
} else {
|
||||
foreach (const QByteArray &abbrev, zone.abbreviations()) {
|
||||
if (QString(abbrev).contains(tz, Qt::CaseInsensitive)) {
|
||||
tzName = abbrev;
|
||||
dt = zoneDateTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (dt.isValid()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return dt;
|
||||
|
|
Loading…
Add table
Reference in a new issue