本文整理汇总了C++中wxDateTime::IsValid方法的典型用法代码示例。如果您正苦于以下问题:C++ wxDateTime::IsValid方法的具体用法?C++ wxDateTime::IsValid怎么用?C++ wxDateTime::IsValid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wxDateTime
的用法示例。
在下文中一共展示了wxDateTime::IsValid方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetRange
void wxDatePickerCtrl::SetRange(const wxDateTime& dt1, const wxDateTime& dt2)
{
SYSTEMTIME st[2];
DWORD flags = 0;
if ( dt1.IsValid() )
{
dt1.GetAsMSWSysTime(st + 0);
flags |= GDTR_MIN;
}
if ( dt2.IsValid() )
{
dt2.GetAsMSWSysTime(st + 1);
flags |= GDTR_MAX;
}
if ( !DateTime_SetRange(GetHwnd(), flags, st) )
{
wxLogDebug(wxT("DateTime_SetRange() failed"));
return;
}
// Setting the range could have changed the current control value if the
// old one wasn't inside the new range, so update it.
m_date = MSWGetControlValue();
}
示例2:
bool
wxGtkCalendarCtrl::SetDateRange(const wxDateTime& lowerdate,
const wxDateTime& upperdate)
{
if ( lowerdate.IsValid() && upperdate.IsValid() && lowerdate >= upperdate )
return false;
m_validStart = lowerdate;
m_validEnd = upperdate;
return true;
}
示例3: GetValue
wxDateTime wxDatePickerCtrl::GetValue() const
{
#if wxDEBUG_LEVEL
const wxDateTime dt = MSWGetControlValue();
wxASSERT_MSG( m_date.IsValid() == dt.IsValid() &&
(!dt.IsValid() || dt == m_date),
wxT("bug in wxDateTimePickerCtrl: m_date not in sync") );
#endif // wxDEBUG_LEVEL
return wxDateTimePickerCtrl::GetValue();
}
示例4: setBegin
void CJournalEntry::setBegin(const wxDateTime& dt)
{
// Avoid silly wxDateTime assertions ... (doh!)
if (m_dtBegin.IsValid() && !dt.IsValid()) {
m_bDirty = true;
} else if (!m_dtBegin.IsValid() && dt.IsValid()) {
m_bDirty = true;
} else {
if (m_dtBegin.IsValid() && dt.IsValid()) {
m_bDirty = m_bDirty || (m_dtBegin != dt);
}
}
m_dtBegin = dt;
}
示例5: SetValue
void wxDatePickerCtrl::SetValue(const wxDateTime& dt)
{
wxCHECK_RET( dt.IsValid() || HasFlag(wxDP_ALLOWNONE),
_T("this control requires a valid date") );
SYSTEMTIME st;
if ( dt.IsValid() )
wxToSystemTime(&st, dt);
if ( !DateTime_SetSystemtime(GetHwnd(),
dt.IsValid() ? GDT_VALID : GDT_NONE,
&st) )
{
wxLogDebug(_T("DateTime_SetSystemtime() failed"));
}
}
示例6: SetUtcTime
void DashboardInstrument_Moon::SetUtcTime( wxDateTime data )
{
if (data.IsValid())
{
m_phase = moon_phase(data.GetYear(), data.GetMonth() + 1, data.GetDay());
}
}
示例7: SetValue
bool
wxDatePickerCtrl::Create(wxWindow *parent,
wxWindowID id,
const wxDateTime& dt,
const wxPoint& pos,
const wxSize& size,
long style,
const wxValidator& validator,
const wxString& name)
{
if ( !wxMSWDateControls::CheckInitialization() )
return false;
// use wxDP_SPIN if wxDP_DEFAULT (0) was given as style
if ( !(style & wxDP_DROPDOWN) )
style |= wxDP_SPIN;
// initialize the base class
if ( !CreateControl(parent, id, pos, size, style, validator, name) )
return false;
// create the native control
if ( !MSWCreateControl(DATETIMEPICK_CLASS, wxEmptyString, pos, size) )
return false;
if ( dt.IsValid() || (style & wxDP_ALLOWNONE) )
SetValue(dt);
else
SetValue(wxDateTime::Today());
return true;
}
示例8: eDocumentPath_shouldUpdateCygwin
//
// Returns true if this Cygwin installation should be updated (or installed for the first time.)
// Returns false if we are up-to-date.
//
bool eDocumentPath_shouldUpdateCygwin(wxDateTime &stampTime, const wxFileName &supportFile){
// E's support folder comes with a network installer for Cygwin.
// Newer versions of E may come with newer Cygwin versions.
// If the user already has Cygwin installed, we still check the
// bundled installer to see if it is newer; if so, then we need to
// re-install Cygwin at the newer version.
if (!stampTime.IsValid())
return true; // First time, so we need to update.
wxDateTime updateTime = supportFile.GetModificationTime();
// Windows doesn't store milliseconds; we clear out this part of the time.
updateTime.SetMillisecond(0);
updateTime.SetSecond(0);
stampTime.SetMillisecond(0);
stampTime.SetSecond(0);
// If the times are the same, no update needed.
if (updateTime == stampTime)
return false;
// ...else the dates differ and we need to update.
wxLogDebug(wxT("InitCygwin: Diff dates"));
wxLogDebug(wxT(" e-postinstall: %s"), updateTime.FormatTime());
wxLogDebug(wxT(" last-e-update: %s"), stampTime.FormatTime());
return true;
}
示例9: wxQtConvertDate
QDate wxQtConvertDate(const wxDateTime& date)
{
if ( date.IsValid() )
return QDate(date.GetYear(), date.GetMonth() + 1, date.GetDay());
else
return QDate();
}
示例10: SetValue
void wxDatePickerCtrl::SetValue(const wxDateTime& dt)
{
if ( dt.IsValid() )
{
// Don't try setting the date if it's out of range: calendar control
// under XP (and presumably all the other pre-Vista Windows versions)
// doesn't return false from DateTime_SetSystemtime() in this case but
// doesn't actually change the date, so we can't update our m_date
// unconditionally and would need to check whether it was changed
// before doing it. It looks simpler to just check whether it's in
// range here instead.
//
// If we ever drop support for XP we could rely on the return value of
// DateTime_SetSystemtime() but this probably won't happen in near
// future.
wxDateTime dtStart, dtEnd;
GetRange(&dtStart, &dtEnd);
if ( (dtStart.IsValid() && dt < dtStart) ||
(dtEnd.IsValid() && dt > dtEnd) )
{
// Fail silently, some existing code relies on SetValue() with an
// out of range value simply doing nothing -- so don't.
return;
}
}
wxDateTimePickerCtrl::SetValue(dt);
// we need to keep only the date part, times don't make sense for this
// control (in particular, comparisons with other dates would fail)
if ( m_date.IsValid() )
m_date.ResetTime();
}
示例11: SetValue
bool
wxDateTimePickerCtrl::MSWCreateDateTimePicker(wxWindow *parent,
wxWindowID id,
const wxDateTime& dt,
const wxPoint& pos,
const wxSize& size,
long style,
const wxValidator& validator,
const wxString& name)
{
if ( !wxMSWDateControls::CheckInitialization() )
return false;
// initialize the base class
if ( !CreateControl(parent, id, pos, size, style, validator, name) )
return false;
// create the native control
if ( !MSWCreateControl(DATETIMEPICK_CLASS, wxString(), pos, size) )
return false;
if ( dt.IsValid() || MSWAllowsNone() )
SetValue(dt);
else
SetValue(wxDateTime::Now());
return true;
}
示例12: DateToStr
wxString DateToStr(const wxDateTime &datetime)
{
if (!datetime.IsValid())
return wxEmptyString;
return datetime.FormatDate() + wxT(" ") + datetime.FormatTime();
}
示例13: wxT
bool
wxCalendarCtrl::Create(wxWindow *parent,
wxWindowID id,
const wxDateTime& dt,
const wxPoint& pos,
const wxSize& size,
long style,
const wxString& name)
{
if ( !wxMSWDateControls::CheckInitialization() )
return false;
// we need the arrows for the navigation
style |= wxWANTS_CHARS;
// initialize the base class
if ( !CreateControl(parent, id, pos, size, style, wxDefaultValidator, name) )
return false;
// create the native control: this is a bit tricky as we want to receive
// double click events but the MONTHCAL_CLASS doesn't use CS_DBLCLKS style
// and so we create our own copy of it which does
static ClassRegistrar s_clsMonthCal;
if ( !s_clsMonthCal.IsInitialized() )
{
// get a copy of standard class and modify it
WNDCLASS wc;
if ( ::GetClassInfo(NULL, MONTHCAL_CLASS, &wc) )
{
wc.lpszClassName = wxT("_wx_SysMonthCtl32");
wc.style |= CS_DBLCLKS;
s_clsMonthCal.Register(wc);
}
else
{
wxLogLastError(wxT("GetClassInfoEx(SysMonthCal32)"));
}
}
const wxChar * const clsname = s_clsMonthCal.IsRegistered()
? static_cast<const wxChar*>(s_clsMonthCal.GetName().t_str())
: MONTHCAL_CLASS;
if ( !MSWCreateControl(clsname, wxEmptyString, pos, size) )
return false;
// initialize the control
UpdateFirstDayOfWeek();
SetDate(dt.IsValid() ? dt : wxDateTime::Today());
SetHolidayAttrs();
UpdateMarks();
Bind(wxEVT_LEFT_DOWN, &wxCalendarCtrl::MSWOnClick, this);
Bind(wxEVT_LEFT_DCLICK, &wxCalendarCtrl::MSWOnDoubleClick, this);
return true;
}
示例14: SetCreateTime
void TrackPoint::SetCreateTime( wxDateTime dt )
{
wxString ts;
if(dt.IsValid())
ts = dt.FormatISODate().Append(_T("T")).Append(dt.FormatISOTime()).Append(_T("Z"));
SetCreateTime(ts);
}
示例15: Create
bool wxGtkCalendarCtrl::Create(wxWindow *parent,
wxWindowID id,
const wxDateTime& date,
const wxPoint& pos,
const wxSize& size,
long style,
const wxString& name)
{
if (!PreCreation(parent, pos, size) ||
!CreateBase(parent, id, pos, size, style, wxDefaultValidator, name))
{
wxFAIL_MSG(wxT("wxGtkCalendarCtrl creation failed"));
return false;
}
m_widget = gtk_calendar_new();
g_object_ref(m_widget);
SetDate(date.IsValid() ? date : wxDateTime::Today());
if (style & wxCAL_NO_MONTH_CHANGE)
g_object_set (G_OBJECT (m_widget), "no-month-change", true, NULL);
if (style & wxCAL_SHOW_WEEK_NUMBERS)
g_object_set (G_OBJECT (m_widget), "show-week-numbers", true, NULL);
g_signal_connect_after(m_widget, "day-selected",
G_CALLBACK (gtk_day_selected_callback),
this);
g_signal_connect_after(m_widget, "day-selected-double-click",
G_CALLBACK (gtk_day_selected_double_click_callback),
this);
g_signal_connect_after(m_widget, "month-changed",
G_CALLBACK (gtk_month_changed_callback),
this);
// connect callbacks that send deprecated events
g_signal_connect_after(m_widget, "prev-month",
G_CALLBACK (gtk_prev_month_callback),
this);
g_signal_connect_after(m_widget, "next-month",
G_CALLBACK (gtk_prev_month_callback),
this);
g_signal_connect_after(m_widget, "prev-year",
G_CALLBACK (gtk_prev_year_callback),
this);
g_signal_connect_after(m_widget, "next-year",
G_CALLBACK (gtk_prev_year_callback),
this);
m_parent->DoAddChild(this);
PostCreation(size);
return true;
}