X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a480d0ab8337f1faf28bfbeb6652bd94dca8eb4e..65baafba0e8cd74f2264b7e2f7625ff5bea84864:/tests/datetime/datetimetest.cpp?ds=sidebyside diff --git a/tests/datetime/datetimetest.cpp b/tests/datetime/datetimetest.cpp index f4adb0d26b..29209eef6c 100644 --- a/tests/datetime/datetimetest.cpp +++ b/tests/datetime/datetimetest.cpp @@ -257,7 +257,9 @@ void DateTimeTestCase::TestTimeJDN() { const Date& d = testDates[n]; wxDateTime dt(d.day, d.month, d.year, d.hour, d.min, d.sec); - double jdn = dt.GetJulianDayNumber(); + + // JDNs must be computed for UTC times + double jdn = dt.FromUTC().GetJulianDayNumber(); CPPUNIT_ASSERT( jdn == d.jdn ); @@ -662,7 +664,7 @@ void DateTimeTestCase::TestTimeTicks() long ticks = (dt.GetValue() / 1000).ToLong(); CPPUNIT_ASSERT( ticks == d.ticks ); - dt = d.DT().ToTimezone(wxDateTime::GMT0); + dt = d.DT().FromTimezone(wxDateTime::GMT0); ticks = (dt.GetValue() / 1000).ToLong(); CPPUNIT_ASSERT( ticks == d.gmticks ); } @@ -674,12 +676,25 @@ void DateTimeTestCase::TestTimeParse() static const struct ParseTestData { const wxChar *format; - Date date; + Date date; // NB: this should be in UTC bool good; } parseTestDates[] = { - { _T("Sat, 18 Dec 1999 00:46:40 +0100"), { 18, wxDateTime::Dec, 1999, 00, 46, 40, 0.0, wxDateTime::Inv_WeekDay, 0, 0 }, true }, - { _T("Wed, 1 Dec 1999 05:17:20 +0300"), { 1, wxDateTime::Dec, 1999, 03, 17, 20, 0.0, wxDateTime::Inv_WeekDay, 0, 0 }, true }, + { + _T("Sat, 18 Dec 1999 00:46:40 +0100"), + { 17, wxDateTime::Dec, 1999, 23, 46, 40, 0.0, wxDateTime::Inv_WeekDay, 0, 0 }, + true + }, + { + _T("Wed, 1 Dec 1999 05:17:20 +0300"), + { 1, wxDateTime::Dec, 1999, 2, 17, 20, 0.0, wxDateTime::Inv_WeekDay, 0, 0 }, + true + }, + { + _T("Sun, 28 Aug 2005 03:31:30 +0200"), + { 28, wxDateTime::Aug, 2005, 1, 31, 30, 0.0, wxDateTime::Inv_WeekDay, 0, 0 }, + true + }, }; for ( size_t n = 0; n < WXSIZEOF(parseTestDates); n++ ) @@ -691,10 +706,7 @@ void DateTimeTestCase::TestTimeParse() { CPPUNIT_ASSERT( parseTestDates[n].good ); - wxDateTime dtReal = parseTestDates[n].date.DT(); - //RN: We need this because the tests are based on - //a non-GMT time zone - dtReal.MakeTimezone(wxDateTime::WEST, true); + wxDateTime dtReal = parseTestDates[n].date.DT().FromUTC(); CPPUNIT_ASSERT( dt == dtReal ); } else // failed to parse @@ -757,6 +769,9 @@ void DateTimeTestCase::TestDSTBug() CPPUNIT_ASSERT_EQUAL(0, (int)dt.GetSecond()); CPPUNIT_ASSERT_EQUAL(0, (int)dt.GetMillisecond()); + dt.Set(1, 0, 0, 0); + CPPUNIT_ASSERT_EQUAL(1, (int)dt.GetHour()); + ///////////////////////// // Test Today() #ifdef CHANGE_SYSTEM_DATE