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(); }
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; }
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(); }
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; }
void wxDatePickerCtrl::SetValue(const wxDateTime& dt) { wxCHECK_RET( dt.IsValid() || HasFlag(wxDP_ALLOWNONE), wxT("this control requires a valid date") ); SYSTEMTIME st; 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; } dt.GetAsMSWSysTime(&st); } if ( !DateTime_SetSystemtime(GetHwnd(), dt.IsValid() ? GDT_VALID : GDT_NONE, &st) ) { // The only expected failure is when the date is out of range but we // already checked for this above. wxFAIL_MSG( wxT("Setting the calendar date unexpectedly failed.") ); // In any case, skip updating m_date below. return; } // we need to keep only the date part, times don't make sense for this // control (in particular, comparisons with other dates would fail) m_date = dt; if ( m_date.IsValid() ) m_date.ResetTime(); }
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")); } }
void wxDatePickerCtrl::SetValue(const wxDateTime& dt) { if ( dt.IsValid() ) m_dt = dt; SetLabel(m_dt.FormatDate()); }
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(!wxControl::Create(parent, id, pos, size, style, validator, name)) return false; wxString label; if ( dt.IsValid() ) { label = dt.FormatDate(); m_dt = dt; } if(!wxControl::PalmCreateControl(selectorTriggerCtl, label, pos, size)) return false; return true; }
void DashboardInstrument_Moon::SetUtcTime( wxDateTime data ) { if (data.IsValid()) { m_phase = moon_phase(data.GetYear(), data.GetMonth() + 1, data.GetDay()); } }
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; }
// // 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; }
QDate wxQtConvertDate(const wxDateTime& date) { if ( date.IsValid() ) return QDate(date.GetYear(), date.GetMonth() + 1, date.GetDay()); else return QDate(); }
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(); }
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; }
wxString DateToStr(const wxDateTime &datetime) { if (!datetime.IsValid()) return wxEmptyString; return datetime.FormatDate() + wxT(" ") + datetime.FormatTime(); }
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; }
void TrackPoint::SetCreateTime( wxDateTime dt ) { wxString ts; if(dt.IsValid()) ts = dt.FormatISODate().Append(_T("T")).Append(dt.FormatISOTime()).Append(_T("Z")); SetCreateTime(ts); }
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; }
bool wxCalendarCtrl::SetDate(const wxDateTime& date) { wxCHECK_MSG( date.IsValid(), false, "invalid date" ); if ( !m_qtCalendar ) return false; m_qtCalendar->blockSignals(true); m_qtCalendar->setSelectedDate(wxQtConvertDate(date)); m_qtCalendar->blockSignals(false); return true; }
void ConfigurationDialog::SetStartDateTime(wxDateTime datetime) { if(datetime.IsValid()) { m_dpStartDate->SetValue(datetime); m_tStartHour->SetValue(wxString::Format(_T("%.3f"), datetime.GetHour() +datetime.GetMinute() / 60.0)); } else { wxMessageDialog mdlg(this, _("Invalid Date Time."), wxString(_("Weather Routing"), wxOK | wxICON_WARNING)); mdlg.ShowModal(); } }
void wxDatePickerCtrl::SetValue(const wxDateTime& dt) { wxCHECK_RET( dt.IsValid() || HasFlag(wxDP_ALLOWNONE), wxT("this control requires a valid date") ); SYSTEMTIME st; if ( dt.IsValid() ) dt.GetAsMSWSysTime(&st); if ( !DateTime_SetSystemtime(GetHwnd(), dt.IsValid() ? GDT_VALID : GDT_NONE, &st) ) { wxLogDebug(wxT("DateTime_SetSystemtime() failed")); } // we need to keep only the date part, times don't make sense for this // control (in particular, comparisons with other dates would fail) m_date = dt; if ( m_date.IsValid() ) m_date.ResetTime(); }
void wxDatePickerCtrl::SetRange(const wxDateTime& dt1, const wxDateTime& dt2) { SYSTEMTIME st[2]; DWORD flags = 0; if ( dt1.IsValid() ) { wxToSystemTime(&st[0], dt1); flags |= GDTR_MIN; } if ( dt2.IsValid() ) { wxToSystemTime(&st[1], dt2); flags |= GDTR_MAX; } if ( !DateTime_SetRange(GetHwnd(), flags, st) ) { wxLogDebug(_T("DateTime_SetRange() failed")); } }
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")); } }
wxGzipOutputStream::wxGzipOutputStream( wxOutputStream& stream, const wxString& originalName /*=wxEmptyString*/, #if wxUSE_DATETIME const wxDateTime& originalTime /*=wxDateTime::Now()*/, #endif int level /*=-1*/, wxMBConv& conv /*=wxConvFile*/) : wxFilterOutputStream(stream) { m_comp = NULL; m_crc = crc32(0, Z_NULL, 0); wxFileName filename(originalName); wxUint32 timestamp = 0; #if wxUSE_DATETIME if (originalTime.IsValid()) timestamp = (originalTime.GetValue() / 1000L).GetLo(); #endif // RFC-1952 specifies ISO-8859-1 for the name. Also it should be just the // name part, no directory, folded to lowercase if case insensitive wxString name = filename.GetFullName(); const wxWX2MBbuf mbName = conv.cWX2MB(name); wxDataOutputStream ds(*m_parent_o_stream); // write signature, method, flags, timestamp, extra flags and OS-code ds.Write16(GZ_MAGIC); ds.Write8(Z_DEFLATED); ds.Write8(mbName && *mbName ? GZ_ORIG_NAME : 0); ds.Write32(timestamp); ds.Write8(level == 1 ? GZ_FASTEST : level == 9 ? GZ_SLOWEST : 0); ds.Write8(255); if (mbName && *mbName) m_parent_o_stream->Write(mbName, strlen(mbName) + 1); m_lasterror = wxSTREAM_WRITE_ERROR; if (!*m_parent_o_stream) { wxLogDebug(wxT("Error writing Gzip header")); return; } m_comp = new wxZlibOutputStream(*m_parent_o_stream, level, wxZLIB_NO_HEADER); if (m_comp) m_lasterror = m_comp->GetLastError(); }
void wxDateTimePickerCtrl::SetValue(const wxDateTime& dt) { wxCHECK_RET( dt.IsValid() || MSWAllowsNone(), wxT("this control requires a valid date") ); SYSTEMTIME st; if ( dt.IsValid() ) dt.GetAsMSWSysTime(&st); if ( !DateTime_SetSystemtime(GetHwnd(), dt.IsValid() ? GDT_VALID : GDT_NONE, &st) ) { // The only expected failure is when the date is out of range but we // already checked for this above. wxFAIL_MSG( wxT("Setting the calendar date unexpectedly failed.") ); // In any case, skip updating m_date below. return; } m_date = dt; }
bool wxTimeSpinCtrl::SetTime(const wxDateTime &time) { if (time.IsValid()) { wxDateTime tt(time); tt.ResetTime(); return SetValue(time - tt); } else { m_txt->SetValue(wxEmptyString); return false; } }
bool wxCalendarCtrl::SetDateRange(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 ( !MonthCal_SetRange(GetHwnd(), flags, st) ) { wxLogDebug(wxT("MonthCal_SetRange() failed")); } return flags != 0; }
wxString calculateTimeDelta(wxDateTime startTime, wxDateTime endTime) { wxString timeStr; if(startTime.IsValid() && endTime.IsValid()) { wxTimeSpan span = endTime - startTime; int days = span.GetDays(); span -= wxTimeSpan::Days(days); int hours = span.GetHours(); span -= wxTimeSpan::Hours(hours); double minutes = (double)span.GetSeconds().ToLong()/60.0; span -= wxTimeSpan::Minutes(span.GetMinutes()); int seconds = (double)span.GetSeconds().ToLong(); timeStr = (days ? wxString::Format(_T("%dd "), days) : _T("")) + (hours || days ? wxString::Format(_T("%02d:%02d"), hours, (int)round(minutes)) : wxString::Format(_T("%02d %02d"), (int)floor(minutes), seconds)); } else { timeStr = _("N/A"); } return timeStr; }
bool VerifySetDate(wxDateTime& date, int year, wxDateTime::Month month, int day, int hour /*=0*/, int minute /*=0*/, int second /*=0*/) { if (year < 1900 || year > 3000) return false; if (month < 0 || month >= 12) return false; int maxDays = wxDateTime::GetNumberOfDays(month, year); if (day > maxDays) return false; date.Set(day, month, year, hour, minute, second); return date.IsValid(); }
void ConfigurationDialog::SetStartDateTime(wxDateTime datetime) { if(datetime.IsValid()) { if(m_WeatherRouting.m_SettingsDialog.m_cbUseLocalTime->GetValue()) datetime = datetime.FromUTC(); m_dpStartDate->SetValue(datetime); m_tpTime->SetValue(datetime); m_edited_controls.push_back(m_tpTime); m_edited_controls.push_back(m_dpStartDate); } else { wxMessageDialog mdlg(this, _("Invalid Date Time."), wxString(_("Weather Routing"), wxOK | wxICON_WARNING)); mdlg.ShowModal(); } }