bool wxCalendarCtrlBase::GenerateAllChangeEvents(const wxDateTime& dateOld) { const wxDateTime::Tm tm1 = dateOld.GetTm(), tm2 = GetDate().GetTm(); bool pageChanged = false; GenerateEvent(wxEVT_CALENDAR_SEL_CHANGED); if ( tm1.year != tm2.year || tm1.mon != tm2.mon ) { GenerateEvent(wxEVT_CALENDAR_PAGE_CHANGED); pageChanged = true; } // send also one of the deprecated events if ( tm1.year != tm2.year ) GenerateEvent(wxEVT_CALENDAR_YEAR_CHANGED); else if ( tm1.mon != tm2.mon ) GenerateEvent(wxEVT_CALENDAR_MONTH_CHANGED); else GenerateEvent(wxEVT_CALENDAR_DAY_CHANGED); return pageChanged; }
static inline void wxToSystemTime(SYSTEMTIME *st, const wxDateTime& dt) { const wxDateTime::Tm tm(dt.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; }
wxString TimerRecordDialog::GetDisplayDate( wxDateTime & dt ) { #if defined(__WXMSW__) // On Windows, wxWidgets uses the system date control and it displays the // date based on the Windows locale selected by the user. But, wxDateTime // using the strftime function to return the formatted date. Since the // default locale for the Windows CRT environment is "C", the dates come // back in a different format. // // So, we make direct Windows calls to format the date like it the date // control. // // (Most of this taken from src/msw/datectrl.cpp) const wxDateTime::Tm tm(dt.GetTm()); SYSTEMTIME st; wxString s; int len; st.wYear = (WXWORD)tm.year; st.wMonth = (WXWORD)(tm.mon - wxDateTime::Jan + 1); st.wDay = tm.mday; st.wDayOfWeek = st.wMinute = st.wSecond = st.wMilliseconds = 0; len = ::GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &st, NULL, NULL, 0); if (len > 0) { len = ::GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &st, NULL, wxStringBuffer(s, len), len); if (len > 0) { s += wxT(" ") + dt.FormatTime(); return s; } } #endif // Use default formatting wxPrintf(wxT("%s\n"), dt.Format().c_str()); return dt.FormatDate() + wxT(" ") + dt.FormatTime(); }
FirebirdParameter::FirebirdParameter(FirebirdInterface* pInterface, XSQLVAR* pVar, const wxDateTime& dateValue) { m_pInterface = pInterface; m_pParameter = pVar; m_nParameterType = FirebirdParameter::PARAM_DATETIME; struct tm dateAsTm; wxDateTime::Tm tm = dateValue.GetTm(); dateAsTm.tm_sec = tm.sec; dateAsTm.tm_min = tm.min; dateAsTm.tm_hour = tm.hour; dateAsTm.tm_mday = tm.mday; dateAsTm.tm_mon = tm.mon; dateAsTm.tm_year = tm.year - 1900; m_pInterface->GetIscEncodeTimestamp()(&dateAsTm, &m_Date); m_nBufferLength = sizeof(ISC_TIMESTAMP); m_pParameter->sqldata = (char*)&m_Date; m_nNullFlag = 0; m_pParameter->sqlind = &m_nNullFlag; // NULL indicator }