conversion/commonconversion.cpp tests/timezonetest.cpp

Christian Mollekopf mollekopf at kolabsys.com
Thu Dec 20 18:36:13 CET 2012


 conversion/commonconversion.cpp |    7 ++++++-
 tests/timezonetest.cpp          |    3 +++
 2 files changed, 9 insertions(+), 1 deletion(-)

New commits:
commit 7818a7b193b7702963b1f24683df8aa5c7c2a593
Author: Christian Mollekopf <mollekopf at kolabsys.com>
Date:   Thu Dec 20 18:36:00 2012 +0100

    Deal with failure to fix the timezone.

diff --git a/conversion/commonconversion.cpp b/conversion/commonconversion.cpp
index 6af1ec0..489a1d6 100644
--- a/conversion/commonconversion.cpp
+++ b/conversion/commonconversion.cpp
@@ -90,7 +90,12 @@ cDateTime fromDate(const KDateTime &dt)
             //TODO handle local timezone?
             //Convert non-olson timezones if necessary
             const QString timezone = TimezoneConverter::normalizeTimezone(dt.timeZone().name());
-            date.setTimezone(toStdString(timezone));
+            if (!timezone.isEmpty()) {
+                date.setTimezone(toStdString(timezone));
+            } else {
+                Error() << "invalid timezone: " << dt.timeZone().name() << " , assuming floating time";
+                return date;
+            }
         } else if (dt.timeType() != KDateTime::ClockTime) {
             Error() << "invalid timespec, assuming floating time" << dt.timeType();
             return date;
diff --git a/tests/timezonetest.cpp b/tests/timezonetest.cpp
index 1850978..54b1fbf 100644
--- a/tests/timezonetest.cpp
+++ b/tests/timezonetest.cpp
@@ -74,6 +74,7 @@ void TimezoneTest::testFromHardcodedList_data()
     QTest::newRow( "11" ) << QString::fromLatin1("(GMT-03:30) Newfoundland and Labrador");
     QTest::newRow( "12" ) << QString::fromLatin1("(GMT-08:00) Pacific Time (US and Canada); Tijuana");
     QTest::newRow( "13" ) << QString::fromLatin1("(GMT-11:00) Midway Island, Samoa");
+    QTest::newRow( "14" ) << QString::fromLatin1("W. Europe Standard Time");
 }
 
 void TimezoneTest::testFromHardcodedList()
@@ -81,7 +82,9 @@ void TimezoneTest::testFromHardcodedList()
     TimezoneConverter converter;
     QFETCH(QString, timezone);
     const QString tz = converter.normalizeTimezone(timezone);
+    kDebug() << tz;
     QVERIFY(!tz.isEmpty());
+    QVERIFY(tz != timezone);
 }
 
 void TimezoneTest::testKolabObjectWriter()





More information about the commits mailing list