From c4e25288355849dc1393aa120b15eaea76152851 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 1 Jun 2008 12:58:43 +0000 Subject: [PATCH] fix time zone conversion test to work in any time zone, not just GMT+1 git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@53893 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- tests/datetime/datetimetest.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/tests/datetime/datetimetest.cpp b/tests/datetime/datetimetest.cpp index 988ee7fe2d..20e93fafae 100644 --- a/tests/datetime/datetimetest.cpp +++ b/tests/datetime/datetimetest.cpp @@ -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); - long ticks = (dt.GetValue() / 1000).ToLong(); - CPPUNIT_ASSERT_EQUAL( d.ticks, ticks ); - dt = d.DT().FromTimezone(wxDateTime::GMT0); + // 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 + tzOffset ); + + dt = d.DT().FromTimezone(wxDateTime::UTC); ticks = (dt.GetValue() / 1000).ToLong(); CPPUNIT_ASSERT_EQUAL( d.gmticks, ticks ); }