From: Vadim Zeitlin Date: Sun, 27 Nov 2011 19:50:33 +0000 (+0000) Subject: Removed private wxGetLocalTimeUsec() function from Unix code. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/cec1b1ab0b03e504470c0689d5098bbcd0e0b2f7 Removed private wxGetLocalTimeUsec() function from Unix code. The function was badly named as it returned UTC time and not local time and can be simply replaced with the just added public wxGetUTCTimeUSec(). git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@69839 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/unix/private/timer.h b/include/wx/unix/private/timer.h index d879f3640d..ceb107c3b1 100644 --- a/include/wx/unix/private/timer.h +++ b/include/wx/unix/private/timer.h @@ -134,12 +134,6 @@ private: static wxTimerScheduler *ms_instance; }; -// this helper function currently only exists for Unix platforms but could be -// moved to wx/stopwatch.h if it turns out to be useful elsewhere -// -// returns the number of microseconds since the Epoch -extern wxUsecClock_t wxGetLocalTimeUsec(); - #endif // wxUSE_TIMER #endif // _WX_UNIX_PRIVATE_TIMER_H_ diff --git a/src/unix/timerunx.cpp b/src/unix/timerunx.cpp index eb2c4e02b1..7ee1177c89 100644 --- a/src/unix/timerunx.cpp +++ b/src/unix/timerunx.cpp @@ -31,6 +31,7 @@ #include "wx/apptrait.h" #include "wx/longlong.h" +#include "wx/time.h" #include "wx/vector.h" #include @@ -125,7 +126,7 @@ bool wxTimerScheduler::GetNext(wxUsecClock_t *remaining) const wxCHECK_MSG( remaining, false, wxT("NULL pointer") ); - *remaining = (*m_timers.begin())->m_expiration - wxGetLocalTimeUsec(); + *remaining = (*m_timers.begin())->m_expiration - wxGetUTCTimeUSec(); if ( *remaining < 0 ) { // timer already expired, don't wait at all before notifying it @@ -140,7 +141,7 @@ bool wxTimerScheduler::NotifyExpired() if ( m_timers.empty() ) return false; - const wxUsecClock_t now = wxGetLocalTimeUsec(); + const wxUsecClock_t now = wxGetUTCTimeUSec(); typedef wxVector TimerImpls; TimerImpls toNotify; @@ -218,7 +219,7 @@ bool wxUnixTimerImpl::Start(int milliseconds, bool oneShot) // notice that this will stop an already running timer wxTimerImpl::Start(milliseconds, oneShot); - wxTimerScheduler::Get().AddTimer(this, wxGetLocalTimeUsec() + m_milli*1000); + wxTimerScheduler::Get().AddTimer(this, wxGetUTCTimeUSec() + m_milli*1000); m_isRunning = true; return true; @@ -264,21 +265,6 @@ IMPLEMENT_DYNAMIC_CLASS(wxTimerUnixModule, wxModule) // global functions // ============================================================================ -wxUsecClock_t wxGetLocalTimeUsec() -{ -#ifdef HAVE_GETTIMEOFDAY - struct timeval tv; - if ( wxGetTimeOfDay(&tv) != -1 ) - { - wxUsecClock_t val = 1000000L; // usec/sec - val *= tv.tv_sec; - return val + tv.tv_usec; - } -#endif // HAVE_GETTIMEOFDAY - - return wxGetLocalTimeMillis() * 1000L; -} - wxTimerImpl *wxConsoleAppTraits::CreateTimerImpl(wxTimer *timer) { return new wxUnixTimerImpl(timer);