Revert wrong fix for wxDateTime timezone conversion to/from local
This reverts commitaaddf6be7fas it broke handling of dates when local time zone is BST, whose offset not counting DST is 0, as for UTC, but which still should be handled as local timezone, see #17220. With the current wxDateTime handling of time zones, FromTimezone(Local) doesn't make much sense anyhow, so abandon attempts to try making it work as to really do it we need to specify the time zone being converted from too, as explained in the second point of #10445. See #16585. (cherry picked from commitf6d9d7962e)
This commit is contained in:
@@ -232,6 +232,7 @@ private:
|
||||
CPPUNIT_TEST( TestTimeArithmetics );
|
||||
CPPUNIT_TEST( TestDSTBug );
|
||||
CPPUNIT_TEST( TestDateOnly );
|
||||
CPPUNIT_TEST( TestConvToFromLocalTZ );
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
void TestLeapYears();
|
||||
@@ -252,6 +253,7 @@ private:
|
||||
void TestTimeArithmetics();
|
||||
void TestDSTBug();
|
||||
void TestDateOnly();
|
||||
void TestConvToFromLocalTZ();
|
||||
|
||||
DECLARE_NO_COPY_CLASS(DateTimeTestCase)
|
||||
};
|
||||
@@ -1447,4 +1449,23 @@ void DateTimeTestCase::TestDateOnly()
|
||||
CPPUNIT_ASSERT_EQUAL( wxDateTime::Today(), wxDateTime::Now().GetDateOnly() );
|
||||
}
|
||||
|
||||
void DateTimeTestCase::TestConvToFromLocalTZ()
|
||||
{
|
||||
// Choose a date when the DST is on in many time zones: in this case,
|
||||
// converting to/from local TZ does modify the object because it
|
||||
// adds/subtracts DST to/from it, so to get the expected results we need to
|
||||
// explicitly disable DST support in these functions.
|
||||
wxDateTime dt(18, wxDateTime::Apr, 2017, 19);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL( dt.FromTimezone(wxDateTime::Local, true), dt );
|
||||
CPPUNIT_ASSERT_EQUAL( dt.ToTimezone(wxDateTime::Local, true), dt );
|
||||
|
||||
// And another one when it is off: in this case, there is no need to pass
|
||||
// "true" as "noDST" argument to these functions.
|
||||
dt = wxDateTime(18, wxDateTime::Jan, 2018, 19);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL( dt.FromTimezone(wxDateTime::Local), dt );
|
||||
CPPUNIT_ASSERT_EQUAL( dt.ToTimezone(wxDateTime::Local), dt );
|
||||
}
|
||||
|
||||
#endif // wxUSE_DATETIME
|
||||
|
||||
Reference in New Issue
Block a user