From 15a97924b66b99c7b7114825a9e349deeddf38a5 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 30 Nov 2017 22:23:29 +0100 Subject: [PATCH] Simplify wxDateTime ticks test by only using UTC times Converting to another time zone and dealing with DST is completely useless here, ticks values are always in UTC, so we can just use UTC values from the beginning. --- tests/datetime/datetimetest.cpp | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/tests/datetime/datetimetest.cpp b/tests/datetime/datetimetest.cpp index 8069c4d845..a5258d417f 100644 --- a/tests/datetime/datetimetest.cpp +++ b/tests/datetime/datetimetest.cpp @@ -1019,32 +1019,17 @@ void DateTimeTestCase::TestTimeSpanFormat() void DateTimeTestCase::TestTimeTicks() { - static const wxDateTime::TimeZone TZ_LOCAL(wxDateTime::Local); - static const wxDateTime::TimeZone TZ_TEST(wxDateTime::NZST); - - // this offset is needed to make the test work in any time zone when we - // only have expected test results in UTC in testDates - static const long tzOffset = TZ_LOCAL.GetOffset() - TZ_TEST.GetOffset(); - for ( size_t n = 0; n < WXSIZEOF(testDates); n++ ) { const Date& d = testDates[n]; if ( d.gmticks == -1 ) continue; - wxDateTime dt = d.DT().MakeTimezone(TZ_TEST, true /* no DST */); + const wxDateTime dt = d.DT().FromTimezone(wxDateTime::UTC); INFO("n=" << n); - // GetValue() returns internal UTC-based representation, we need to - // convert it to local TZ before comparing - time_t ticks = (dt.GetValue() / 1000).ToLong() + TZ_LOCAL.GetOffset(); - if ( dt.IsDST() ) - ticks += 3600; - CHECK( d.gmticks == ticks + tzOffset ); - - dt = d.DT().FromTimezone(wxDateTime::UTC); - ticks = (dt.GetValue() / 1000).ToLong(); + time_t ticks = (dt.GetValue() / 1000).ToLong(); CHECK( d.gmticks == ticks ); } }