]> git.saurik.com Git - wxWidgets.git/commitdiff
fix time zone conversion test to work in any time zone, not just GMT+1
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 1 Jun 2008 12:58:43 +0000 (12:58 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 1 Jun 2008 12:58:43 +0000 (12:58 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@53893 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

tests/datetime/datetimetest.cpp

index 988ee7fe2d6b6651a6ddfa47197b7f8d8dab8de3..20e93fafae0104bc1fde4d62bae5dbe3a5adc469 100644 (file)
@@ -719,6 +719,13 @@ void DateTimeTestCase::TestTimeSpanFormat()
 
 void DateTimeTestCase::TestTimeTicks()
 {
+    static const wxDateTime::TZ TZ_TEST = wxDateTime::NZST;
+
+    // this test depends on the local time zone so to make it work everywhere
+    // we need to adjust the expected results
+    const long tzOffset = wxDateTime::TimeZone(wxDateTime::Local).GetOffset() -
+                          wxDateTime::TimeZone(TZ_TEST).GetOffset();
+
     for ( size_t n = 0; n < WXSIZEOF(testDates); n++ )
     {
         const Date& d = testDates[n];
@@ -726,14 +733,13 @@ void DateTimeTestCase::TestTimeTicks()
             continue;
 
         wxDateTime dt = d.DT();
-        //RN:  Translate according to test's time zone
-        //2nd param is to ignore DST - it's already factored
-        //into Vadim's tests
-        dt.MakeTimezone(wxDateTime::WEST, true);
+
+        // ignore DST, the test data already takes it into account
+        dt.MakeTimezone(TZ_TEST, true);
         long ticks = (dt.GetValue() / 1000).ToLong();
-        CPPUNIT_ASSERT_EQUAL( d.ticks, ticks );
+        CPPUNIT_ASSERT_EQUAL( d.ticks, ticks + tzOffset );
 
-        dt = d.DT().FromTimezone(wxDateTime::GMT0);
+        dt = d.DT().FromTimezone(wxDateTime::UTC);
         ticks = (dt.GetValue() / 1000).ToLong();
         CPPUNIT_ASSERT_EQUAL( d.gmticks, ticks );
     }