From: Francesco Montorsi Date: Fri, 20 Mar 2009 22:07:09 +0000 (+0000) Subject: share a few helpers between datetime.cpp and datetimefmt.cpp X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/1ee2f9d96d962a1d02d144e1c3c36d8103d8ccbb share a few helpers between datetime.cpp and datetimefmt.cpp git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@59677 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/common/datetime.cpp b/src/common/datetime.cpp index d4c2925d7c..164cc5b705 100644 --- a/src/common/datetime.cpp +++ b/src/common/datetime.cpp @@ -382,7 +382,8 @@ wxDateTime::wxDateTime_t GetNumOfDaysInMonth(int year, wxDateTime::Month month) // returns the time zone in the C sense, i.e. the difference UTC - local // (in seconds) -static int GetTimeZone() +// NOTE: not static because used by datetimefmt.cpp +int GetTimeZone() { // set to true when the timezone is set static bool s_timezoneSet = false; @@ -455,7 +456,8 @@ static long GetTruncatedJDN(wxDateTime::wxDateTime_t day, #ifdef HAVE_STRFTIME // this function is a wrapper around strftime(3) adding error checking -static wxString CallStrftime(const wxString& format, const tm* tm) +// NOTE: not static because used by datetimefmt.cpp +wxString CallStrftime(const wxString& format, const tm* tm) { wxChar buf[4096]; // Create temp wxString here to work around mingw/cygwin bug 1046059 @@ -499,8 +501,9 @@ static void ReplaceDefaultYearMonthWithCurrent(int *year, } } -// fll the struct tm with default values -static void InitTm(struct tm& tm) +// fill the struct tm with default values +// NOTE: not static because used by datetimefmt.cpp +void InitTm(struct tm& tm) { // struct tm may have etxra fields (undocumented and with unportable // names) which, nevertheless, must be set to 0 @@ -665,6 +668,13 @@ wxDateTime::TimeZone::TimeZone(wxDateTime::TZ tz) // static functions // ---------------------------------------------------------------------------- +/* static */ +struct tm *wxDateTime::GetTmNow(struct tm *tmstruct) +{ + time_t t = GetTimeNow(); + return wxLocaltime_r(&t, tmstruct); +} + /* static */ bool wxDateTime::IsLeapYear(int year, wxDateTime::Calendar cal) { diff --git a/src/common/datetimefmt.cpp b/src/common/datetimefmt.cpp index 845d8ead32..98c70a6cd1 100644 --- a/src/common/datetimefmt.cpp +++ b/src/common/datetimefmt.cpp @@ -63,6 +63,16 @@ // implementation of wxDateTime // ============================================================================ +// ---------------------------------------------------------------------------- +// helpers shared between datetime.cpp and datetimefmt.cpp +// ---------------------------------------------------------------------------- + +extern void InitTm(struct tm& tm); + +extern int GetTimeZone(); + +extern wxString CallStrftime(const wxString& format, const tm* tm); + // ---------------------------------------------------------------------------- // constants (see also datetime.cpp) // ---------------------------------------------------------------------------- @@ -174,13 +184,6 @@ static wxDateTime::WeekDay GetWeekDayFromName(const wxString& name, int flags) return wd; } -/* static */ -struct tm *wxDateTime::GetTmNow(struct tm *tmstruct) -{ - time_t t = GetTimeNow(); - return wxLocaltime_r(&t, tmstruct); -} - // scans all digits (but no more than len) and returns the resulting number static bool GetNumericToken(size_t len, const wxStringCharType*& p,