From: Vadim Zeitlin Date: Fri, 10 Dec 1999 20:59:08 +0000 (+0000) Subject: and now timezones work even better ;-) X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/151d66be0fb2af0b98e40e8e0d62e9b6bb7b1c2e and now timezones work even better ;-) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4897 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/samples/console/console.cpp b/samples/console/console.cpp index 1b29d30af2..f94b716028 100644 --- a/samples/console/console.cpp +++ b/samples/console/console.cpp @@ -359,13 +359,6 @@ static void TestTimeSet() { puts("\n*** wxDateTime construction test ***"); -#if 0 - printf("Current time:\t%s\n", wxDateTime::Now().Format().c_str()); - printf("Unix epoch:\t%s\n", wxDateTime((time_t)0).Format().c_str()); - printf("Today noon:\t%s\n", wxDateTime(12, 0).Format().c_str()); - printf("May 29, 1976:\t%s\n", wxDateTime(29, wxDateTime::May, 1976).Format().c_str()); - printf("Jan 1, 1900:\t%s\n", wxDateTime(1, wxDateTime::Jan, 1900).Format().c_str()); -#else for ( size_t n = 0; n < WXSIZEOF(testDates); n++ ) { const Date& d1 = testDates[n]; @@ -381,7 +374,6 @@ static void TestTimeSet() s1.c_str(), s2.c_str(), s1 == s2 ? "ok" : "ERROR"); } -#endif } // test time zones stuff @@ -926,8 +918,8 @@ int main(int argc, char **argv) TestTimeZones(); TestTimeRange(); TestTimeTicks(); - TestTimeJDN(); } + TestTimeJDN(); #endif // TEST_TIME wxUninitialize(); diff --git a/src/common/datetime.cpp b/src/common/datetime.cpp index 10f35b10fb..815813e151 100644 --- a/src/common/datetime.cpp +++ b/src/common/datetime.cpp @@ -688,6 +688,7 @@ wxDateTime::Tm wxDateTime::GetTm(const TimeZone& tz) const } else { + time += tz.GetOffset(); tm = gmtime(&time); } @@ -701,7 +702,7 @@ wxDateTime::Tm wxDateTime::GetTm(const TimeZone& tz) const // remember the time and do the calculations with the date only - this // eliminates rounding errors of the floating point arithmetics - wxLongLong timeMidnight = m_time - GetTimeZone() * 1000; + wxLongLong timeMidnight = m_time + tz.GetOffset() * 1000; long timeOnly = (timeMidnight % MILLISECONDS_PER_DAY).ToLong();