summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Mollekopf <mollekopf@kolabsys.com>2013-10-28 09:21:59 (GMT)
committerChristian Mollekopf <mollekopf@kolabsys.com>2013-10-29 08:29:43 (GMT)
commitc0d1980d6a411c32fb375fdc154878f1076008ff (patch)
tree5e79db882b4ea0aa109373976961765aefeb2653
parentf0cc50f63841d28f3cacc53d3800bcf2d9c737be (diff)
downloadlibkolab-c0d1980d6a411c32fb375fdc154878f1076008ff.tar.gz
Only issue a warning on unknown timezone, and fallback to floating time.
This way unknown timezones don't completely block the conversion of kolab objects.
-rw-r--r--conversion/commonconversion.cpp10
1 files changed, 4 insertions, 6 deletions
diff --git a/conversion/commonconversion.cpp b/conversion/commonconversion.cpp
index 87b35c2..3546395 100644
--- a/conversion/commonconversion.cpp
+++ b/conversion/commonconversion.cpp
@@ -39,19 +39,17 @@ KDateTime::Spec getTimeSpec(bool isUtc, const std::string& timezone)
//Convert non-olson timezones if necessary
const QString normalizedTz = TimezoneConverter::normalizeTimezone(QString::fromStdString(timezone));
- Debug() << "normalized " << normalizedTz;
KTimeZone tz = KSystemTimeZones::zone(normalizedTz); //Needs ktimezoned (timezone daemon running) http://api.kde.org/4.x-api/kdelibs-apidocs/kdecore/html/classKSystemTimeZones.html
if (!tz.isValid()) {
- Error() << "timezone not found" << QString::fromStdString(timezone);
+ Warning() << "invalid timezone: " << QString::fromStdString(timezone) << ", assuming floating time";
if (!KSystemTimeZones::isTimeZoneDaemonAvailable()) {
Error() << "ktimezoned is not available and required for timezone interpretation";
}
- tz = KTimeZone::utc(); //Don't crash
+ return KDateTime::Spec(KDateTime::ClockTime);
}
return KDateTime::Spec(tz);
}
-
KDateTime toDate(const Kolab::cDateTime &dt)
{
KDateTime date;
@@ -97,11 +95,11 @@ cDateTime fromDate(const KDateTime &dt)
if (!timezone.isEmpty()) {
date.setTimezone(toStdString(timezone));
} else {
- Error() << "invalid timezone: " << dt.timeZone().name() << " , assuming floating time";
+ Warning() << "invalid timezone: " << dt.timeZone().name() << ", assuming floating time";
return date;
}
} else if (dt.timeType() != KDateTime::ClockTime) {
- Error() << "invalid timespec, assuming floating time" << dt.timeType();
+ Error() << "invalid timespec, assuming floating time. Type: " << dt.timeType() << "dt: " << dt.toString();
return date;
}
}