X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e4d0689515f282838013f74525ac5d37c53fa518..8244507f687f59a6493948cc4482ee19f82e66c5:/src/common/datetime.cpp diff --git a/src/common/datetime.cpp b/src/common/datetime.cpp index e9f1935bb3..2a26b7b121 100644 --- a/src/common/datetime.cpp +++ b/src/common/datetime.cpp @@ -137,30 +137,16 @@ wxCUSTOM_TYPE_INFO(wxDateTime, wxToStringConverter , wxFromStringCon #define WX_TIMEZONE wxGetTimeZone() #elif defined(__DARWIN__) #define WX_GMTOFF_IN_TM - #elif defined(__WXWINCE__) && defined(__VISUALC8__) - // _timezone is not present in dynamic run-time library - #if 0 - // Solution (1): use the function equivalent of _timezone + #elif wxCHECK_VISUALC_VERSION(8) + // While _timezone is still present in (some versions of) VC CRT, it's + // deprecated and _get_timezone() should be used instead. static long wxGetTimeZone() { long t; - _get_timezone(& t); + _get_timezone(&t); return t; } #define WX_TIMEZONE wxGetTimeZone() - #elif 1 - // Solution (2): using GetTimeZoneInformation - static long wxGetTimeZone() - { - TIME_ZONE_INFORMATION tzi; - ::GetTimeZoneInformation(&tzi); - return tzi.Bias; // x 60 - } - #define WX_TIMEZONE wxGetTimeZone() - #else - // Old method using _timezone: this symbol doesn't exist in the dynamic run-time library (i.e. using /MD) - #define WX_TIMEZONE _timezone - #endif #else // unknown platform - try timezone #define WX_TIMEZONE timezone #endif @@ -508,8 +494,12 @@ wxDateTime::Tm::Tm() { year = (wxDateTime_t)wxDateTime::Inv_Year; mon = wxDateTime::Inv_Month; - mday = 0; - hour = min = sec = msec = 0; + mday = + yday = 0; + hour = + min = + sec = + msec = 0; wday = wxDateTime::Inv_WeekDay; } @@ -1612,6 +1602,7 @@ wxDateTime::Tm wxDateTime::GetTm(const TimeZone& tz) const // construct Tm from these values Tm tm; tm.year = (int)year; + tm.yday = (wxDateTime_t)(dayOfYear - 1); // use C convention for day number tm.mon = (Month)(month - 1); // algorithm yields 1 for January, not 0 tm.mday = (wxDateTime_t)day; tm.msec = (wxDateTime_t)(timeOnly % 1000); @@ -2347,6 +2338,14 @@ wxDateTime& wxDateTime::SetFromMSWSysTime(const SYSTEMTIME& st) st.wHour, st.wMinute, st.wSecond, st.wMilliseconds); } +wxDateTime& wxDateTime::SetFromMSWSysDate(const SYSTEMTIME& st) +{ + return Set(st.wDay, + static_cast(wxDateTime::Jan + st.wMonth - 1), + st.wYear, + 0, 0, 0, 0); +} + void wxDateTime::GetAsMSWSysTime(SYSTEMTIME* st) const { const wxDateTime::Tm tm(GetTm()); @@ -2361,6 +2360,22 @@ void wxDateTime::GetAsMSWSysTime(SYSTEMTIME* st) const st->wSecond = tm.sec; st->wMilliseconds = tm.msec; } + +void wxDateTime::GetAsMSWSysDate(SYSTEMTIME* st) const +{ + const wxDateTime::Tm tm(GetTm()); + + st->wYear = (WXWORD)tm.year; + st->wMonth = (WXWORD)(tm.mon - wxDateTime::Jan + 1); + st->wDay = tm.mday; + + st->wDayOfWeek = + st->wHour = + st->wMinute = + st->wSecond = + st->wMilliseconds = 0; +} + #endif // __WXMSW__ #endif // wxUSE_DATETIME