bool CUpdater::Run() { if( state_ != UpdaterState::idle && state_ != UpdaterState::failed && state_ != UpdaterState::newversion && state_ != UpdaterState::newversion_ready ) { return false; } wxDateTime const t = wxDateTime::Now(); COptions::Get()->SetOption(OPTION_UPDATECHECK_LASTDATE, t.Format(_T("%Y-%m-%d %H:%M:%S"))); local_file_.clear(); log_ = wxString::Format(_("Started update check on %s\n"), t.Format()); wxString build = CBuildInfo::GetBuildType(); if( build.empty() ) { build = _("custom"); } log_ += wxString::Format(_("Own build type: %s\n"), build); SetState(UpdaterState::checking); m_use_internal_rootcert = true; int res = Download(GetUrl(), wxString()); if (res != FZ_REPLY_WOULDBLOCK) { SetState(UpdaterState::failed); } raw_version_information_.clear(); return state_ == UpdaterState::checking; }
void serverPage::EnableCaching(wxDateTime expire_date) { D(debug("serverPage::EnableCaching(%s)\n", expire_date.Format(wxDefaultDateTimeFormat).c_str())); m_bEnableCaching = true; m_sCacheExpires = expire_date.Format(wxT("%a, %d %b %Y %T GMT") , wxDateTime::UTC ); return; }
wxString FormatDateLong( const wxDateTime &aDate ) { /* GetInfo was introduced only on wx 2.9; for portability reason an * hardcoded format is used on wx 2.8 */ #if wxCHECK_VERSION( 2, 9, 0 ) return aDate.Format( wxLocale::GetInfo( wxLOCALE_LONG_DATE_FMT ) ); #else return aDate.Format( wxT("%d %b %Y") ); #endif }
void GraphView::GetDistance(int x, int y, double &d, wxDateTime &time) const { d = INFINITY; time = wxInvalidDateTime; /* this defines search radius for 'direct hit' */ int w,h; m_dc->GetSize(&w, &h); /* forget about top and bottom margins */ h -= m_bottommargin + m_topmargin; /* get X coordinate */ int index = GetIndex(x); const Draw::VT& vt = m_draw->GetValuesTable(); int i, j; for (i = j = index; i >= 0 || j < (int)vt.size(); --i, ++j) { double d1 = INFINITY; double d2 = INFINITY; if (i >= 0 && i < (int)vt.size() && vt.at(i).IsData()) { int xi, yi; GetPointPosition(m_dc, i, &xi, &yi); d1 = (x - xi) * (x - xi) + (y - yi) * (y - yi); } if (j >= 0 && j < (int)vt.size() && vt.at(j).IsData()) { int xj, yj; GetPointPosition(m_dc, j, &xj, &yj); d1 = (x - xj) * (x - xj) + (y - yj) * (y - yj); } if (!std::isfinite(d1) && !std::isfinite(d1)) continue; if (!std::isfinite(d2) || d1 < d2) { d = d1; time = m_draw->GetTimeOfIndex(i); wxLogInfo(_T("Nearest index %d, time: %s"), i, time.Format().c_str()); } else { d = d2; time = m_draw->GetTimeOfIndex(j); wxLogInfo(_T("Nearest index %d, time: %s"), j, time.Format().c_str()); } break; } }
void GCDCGraphs::GetDistance(size_t draw_index, int x, int y, double &d, wxDateTime &time) { d = INFINITY; time = wxInvalidDateTime; /* this defines search radius for 'direct hit' */ int w,h; GetClientSize(&w, &h); const Draw::VT& vt = m_draws[draw_index]->GetValuesTable(); /* forget about top and bottom margins */ h -= m_screen_margins.bottommargin + m_screen_margins.topmargin; /* get X coordinate */ int index = GetIndex(x, vt.size()); int i, j; for (i = j = index; i >= 0 || j < (int)vt.size(); --i, ++j) { double d1 = INFINITY; double d2 = INFINITY; if (i >= 0 && i < (int)vt.size() && vt.at(i).IsData()) { double xi = GetX(i); double yi = GetY(vt[i].val, m_draws[draw_index]->GetDrawInfo()); d1 = (x - xi) * (x - xi) + (y - yi) * (y - yi); } if (j >= 0 && j < (int)vt.size() && vt.at(j).IsData()) { double xj = GetX(j); double yj = GetY(vt[j].val, m_draws[draw_index]->GetDrawInfo()); d2 = (x - xj) * (x - xj) + (y - yj) * (y - yj); } if (!std::isfinite(d1) && !std::isfinite(d2)) continue; if (!std::isfinite(d2) || d1 < d2) { d = d1; time = m_draws[draw_index]->GetTimeOfIndex(i); wxLogInfo(_T("Nearest index %d, time: %s"), i, time.Format().c_str()); } else { d = d2; time = m_draws[draw_index]->GetTimeOfIndex(j); wxLogInfo(_T("Nearest index %d, time: %s"), j, time.Format().c_str()); } break; } }
void TdsPreparedStatement::SetParamDate(int nPosition, const wxDateTime& dateValue) { //fprintf(stderr, "Setting param %d to date %s\n", nPosition, dateValue.Format().c_str()); ResetErrorCodes(); AllocateParameter(nPosition); wxString dateAsString = dateValue.Format(wxT("%Y-%m-%d %H:%M:%S")); //fprintf(stderr, "Setting param %d to date %s\n", nPosition, dateAsString.c_str()); CONV_RESULT cr; wxCharBuffer dateCharBuffer = ConvertToUnicodeStream(dateAsString); int bufferLength = GetEncodedStreamLength(dateAsString); int ret = tds_convert(this->m_pDatabase->tds_ctx, SYBVARCHAR, (TDS_CHAR*)(const char*)dateCharBuffer, bufferLength, SYBDATETIME, &cr); //fprintf(stderr, "tds_convert returned %d, sizeof TDS_DATETIME = %d\n", ret, sizeof(TDS_DATETIME)); int valueSize = (ret < 0) ? sizeof(TDS_DATETIME) : ret; TDSCOLUMN* curcol = m_pParameters->columns[nPosition-1]; curcol->column_type = SYBDATETIMN; curcol->on_server.column_type = SYBDATETIMN; curcol->column_size = valueSize; curcol->on_server.column_size = valueSize; curcol->column_varint_size = 1; curcol->column_cur_size = valueSize; //tds_alloc_param_data(m_pParameters, curcol); tds_alloc_param_data(curcol); memcpy(curcol->column_data, &cr.dt, valueSize); }
wxString CompDateAxis::GetSpanLabel(wxDateTime date, wxDateSpan span) { int days = span.GetDays(); int weeks = span.GetWeeks(); int months = span.GetMonths(); int years = span.GetYears(); if (days != 0 && weeks == 0 && months == 0 && years == 0) { // days span int startDay = date.GetDay(); int endDay = startDay + days; wxDateTime::wxDateTime_t maxDay = wxDateTime::GetNumberOfDays(date.GetMonth(), date.GetYear()); if (endDay > maxDay) { endDay -= maxDay; } return FormatInterval(startDay, endDay); } else if (days == 0 && weeks != 0 && months == 0 && years == 0) { // weeks span int startWeek = date.GetWeekOfMonth(); int endWeek = startWeek + weeks; return FormatInterval(startWeek, endWeek); } else if (days == 0 && weeks == 0 && months != 0 && years == 0) { // monthes span int startMonth = MonthNum(date.GetMonth()); int endMonth = startMonth + months; if (endMonth > 12) { endMonth = endMonth % 12; } if (months == 1) { return wxDateTime::GetMonthName(MonthFromNum(startMonth)); } else { return wxString::Format(wxT("%s-%s"), wxDateTime::GetMonthName(MonthFromNum(startMonth)).c_str(), wxDateTime::GetMonthName(MonthFromNum(endMonth)).c_str()); } } else if (days == 0 && weeks == 0 && months == 0 && years != 0) { // years span int startYear = date.GetYear(); int endYear = startYear + years; return FormatInterval(startYear, endYear); } else { // we have unaligned span, so print start-end dates wxDateTime endDate = date; endDate += span; return wxString::Format(wxT("%s-%s"), date.Format(wxT("%d-%m-%y")).c_str(), endDate.Format(wxT("%d-%m-%y")).c_str()); } }
wxString otcurrentUIDialog::MakeDateTimeLabel(wxDateTime myDateTime) { const wxString dateLabel(myDateTime.Format( _T( "%a") )); m_staticTextDatetime->SetLabel(dateLabel); m_datePickerDate->SetValue(myDateTime.GetDateOnly()); m_timePickerTime->SetTime(myDateTime.GetHour(),myDateTime.GetMinute(), myDateTime.GetSecond()); return dateLabel; }
wxString nwxString::FormatDateTime(const wxDateTime &dt, const wxString &sDefault) { wxString sRtn; if(dt.GetTicks() == 0) { sRtn = sDefault; } else { sRtn = dt.Format(nwxString::TIME_FORMAT); } return sRtn; }
bool CUpdater::Run() { if( state_ != idle && state_ != failed && state_ != newversion && state_ != newversion_ready ) { return false; } wxDateTime const t = wxDateTime::Now(); COptions::Get()->SetOption(OPTION_UPDATECHECK_LASTDATE, t.Format(_T("%Y-%m-%d %H:%M:%S"))); local_file_.clear(); log_ = wxString::Format(_("Started update check on %s\n"), t.Format().c_str()); SetState(checking); update_options_->m_use_internal_rootcert = true; int res = Download(GetUrl(), _T("")); if (res != FZ_REPLY_WOULDBLOCK) { SetState(failed); } raw_version_information_.clear(); return state_ == checking; }
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(); }
void TraceLogFrame::AddEntry(const wxDateTime &stamp, int pid, const wxString &txt) { wxListItem i; i.SetColumn(0); i.SetText(stamp.Format(wxT("%c"))); i.SetId(m_pCtrlTraceLog->GetItemCount()); long idx = m_pCtrlTraceLog->InsertItem(i); i.SetId(idx); i.SetColumn(1); i.SetText(wxString::Format(wxT("%d"), pid)); m_pCtrlTraceLog->SetItem(i); i.SetColumn(2); i.SetText(txt); m_pCtrlTraceLog->SetItem(i); m_pCtrlTraceLog->SetColumnWidth(0, wxLIST_AUTOSIZE); m_pCtrlTraceLog->SetColumnWidth(1, wxLIST_AUTOSIZE); m_pCtrlTraceLog->SetColumnWidth(2, wxLIST_AUTOSIZE); }
const void * MyConnection::OnRequest(const wxString& topic, const wxString& item, size_t *size, wxIPCFormat format) { *size = 0; wxString s, afterDate; if ( item.StartsWith("Date", &afterDate) ) { const wxDateTime now = wxDateTime::Now(); if ( afterDate.empty() ) { s = now.Format(); *size = wxNO_LEN; } else if ( afterDate == "+len" ) { s = now.FormatTime() + " " + now.FormatDate(); *size = strlen(s.mb_str()) + 1; } } else if ( item == "bytes[3]" ) { s = "123"; *size = 3; } if ( !*size ) { wxLogMessage("Unknown request for \"%s\"", item); return NULL; } // store the data pointer to which we return in a member variable to ensure // that the pointer remains valid even after we return m_requestData = s.mb_str(); const void * const data = m_requestData; Log("OnRequest", topic, item, data, *size, format); return data; }
wxString timestamp2s(wxDateTime ts, int tz_selection, long LMT_offset, int format) { wxString s = _T(""); wxString f; if (format == INPUT_FORMAT) f = _T("%m/%d/%Y %H:%M"); else if (format == TIMESTAMP_FORMAT) f = _T("%m/%d/%Y %H:%M:%S"); else f = _T(" %m/%d %H:%M"); switch (tz_selection) { case 0: s.Append(ts.Format(f)); if (format != INPUT_FORMAT) s.Append(_T(" UT")); break; case 1: s.Append(ts.FromUTC().Format(f)); break; case 2: wxTimeSpan lmt(0,0,(int)LMT_offset,0); s.Append(ts.Add(lmt).Format(f)); if (format != INPUT_FORMAT) s.Append(_T(" LMT")); } return(s); }
void MyServer::Advise() { if ( CanAdvise() ) { const wxDateTime now = wxDateTime::Now(); m_connection->Advise(m_connection->m_advise, now.Format()); const wxString s = now.FormatTime() + " " + now.FormatDate(); m_connection->Advise(m_connection->m_advise, s.mb_str(), wxNO_LEN); #if wxUSE_DDE_FOR_IPC wxLogMessage("DDE Advise type argument cannot be wxIPC_PRIVATE. " "The client will receive it as wxIPC_TEXT, " " and receive the correct no of bytes, " "but not print a correct log entry."); #endif char bytes[3] = { '1', '2', '3' }; m_connection->Advise(m_connection->m_advise, bytes, 3, wxIPC_PRIVATE); } }
void wxSqlitePreparedStatement::SetParamDate(int nPosition, const wxDateTime& dateValue) { ResetErrorCodes(); if (dateValue.IsValid()) { int nIndex = FindStatementAndAdjustPositionIndex(&nPosition); if (nIndex > -1) { sqlite3_reset(m_Statements[nIndex]); wxCharBuffer valueBuffer = ConvertToUnicodeStream(dateValue.Format(_("%Y-%m-%d %H:%M:%S"))); int nReturn = sqlite3_bind_text(m_Statements[nIndex], nPosition, valueBuffer, -1, SQLITE_TRANSIENT); if (nReturn != SQLITE_OK) { SetErrorCode(wxSqliteDatabase::TranslateErrorCode(nReturn)); SetErrorMessage(ConvertFromUnicodeStream(sqlite3_errmsg(m_pDatabase))); ThrowDatabaseException(); } } } else { int nIndex = FindStatementAndAdjustPositionIndex(&nPosition); if (nIndex > -1) { sqlite3_reset(m_Statements[nIndex]); int nReturn = sqlite3_bind_null(m_Statements[nIndex], nPosition); if (nReturn != SQLITE_OK) { SetErrorCode(wxSqliteDatabase::TranslateErrorCode(nReturn)); SetErrorMessage(ConvertFromUnicodeStream(sqlite3_errmsg(m_pDatabase))); ThrowDatabaseException(); } } } }
/// Formats a wxDateTime value using the short format representation of the /// user's locale /// @param dateTime wxDateTime value to format /// @return Formatted string wxString wxGetLocaleShortDateTime(const wxDateTime& dateTime) { //------Last Verified------// // - Nov 29, 2004 return (dateTime.Format()); }
void CStatusView::AddToLog(enum MessageType messagetype, const wxString& message, const wxDateTime& time) { if (!m_shown) { struct t_line line; line.messagetype = messagetype; line.message = message; line.time = time; m_hiddenLines.push_back(line); if (m_hiddenLines.size() > MAX_LINECOUNT) m_hiddenLines.pop_front(); return; } const int messageLength = message.Length(); wxString prefix; prefix.Alloc(25 + messageLength); if (m_nLineCount) prefix = _T("\n"); #ifndef __WXGTK__ wxWindowUpdateLocker *pLock = 0; #endif //__WXGTK__ if (m_nLineCount == MAX_LINECOUNT) { #ifndef __WXGTK__ pLock = new wxWindowUpdateLocker(m_pTextCtrl); #endif //__WXGTK__ int oldLength = m_lineLengths.front(); #ifdef __WXMAC__ m_insertionPoint -= oldLength + 1; #endif m_pTextCtrl->Remove(0, oldLength + 1); m_lineLengths.pop_front(); #ifdef __WXMAC__ m_pTextCtrl->SetInsertionPoint(m_insertionPoint); #endif } else m_nLineCount++; int lineLength = m_attributeCache[messagetype].len + messageLength; if (m_showTimestamps) { if (time != m_lastTime) { m_lastTime = time; #ifndef __WXMAC__ m_lastTimeString = time.Format(_T("%H:%M:%S\t")); #else // Tabs on OS X cannot be freely positioned m_lastTimeString = time.Format(_T("%H:%M:%S ")); #endif } prefix += m_lastTimeString; lineLength += m_lastTimeString.Len(); } #ifdef __WXMAC__ int current = m_pTextCtrl->GetInsertionPoint(); if (current != m_insertionPoint) { m_pTextCtrl->SetInsertionPointEnd(); m_insertionPoint = m_pTextCtrl->GetInsertionPoint(); } m_pTextCtrl->SetStyle(m_insertionPoint, m_insertionPoint, m_attributeCache[messagetype].attr); #else m_pTextCtrl->SetDefaultStyle(m_attributeCache[messagetype].attr); #endif prefix += m_attributeCache[messagetype].prefix; if (m_rtl) { // Unicode control characters that control reading direction const wxChar LTR_MARK = 0x200e; //const wxChar RTL_MARK = 0x200f; const wxChar LTR_EMBED = 0x202A; //const wxChar RTL_EMBED = 0x202B; //const wxChar POP = 0x202c; //const wxChar LTR_OVERRIDE = 0x202D; //const wxChar RTL_OVERRIDE = 0x202E; if (messagetype == Command || messagetype == Response || messagetype >= Debug_Warning) { // Commands, responses and debug message contain English text, // set LTR reading order for them. prefix += LTR_MARK; prefix += LTR_EMBED; lineLength += 2; } } m_lineLengths.push_back(lineLength); prefix += message; #if defined(__WXGTK__) // AppendText always calls SetInsertionPointEnd, which is very expensive. // This check however is negligible. if (m_pTextCtrl->GetInsertionPoint() != m_pTextCtrl->GetLastPosition()) m_pTextCtrl->AppendText(prefix); else m_pTextCtrl->WriteText(prefix); #elif defined(__WXMAC__) m_pTextCtrl->WriteText(prefix); m_insertionPoint += lineLength; if (m_nLineCount > 1) m_insertionPoint += 1; delete pLock; #elif !defined(__WXMAC__) m_pTextCtrl->AppendText(prefix); delete pLock; #endif //__WXGTK__ }
const wxString mmGetDateForDisplay(const wxDateTime &dt) { return dt.Format(mmOptions::instance().dateFormat_); }
void UpdateTextWithoutEvent() { m_text->SetValue(m_time.Format(m_useAMPM ? "%I:%M:%S %p" : "%H:%M:%S")); HighlightCurrentField(); }
PostgresParameter::PostgresParameter(const wxDateTime& dateValue) { m_nParameterType = PostgresParameter::PARAM_DATETIME; m_strDateValue = dateValue.Format(wxT("%Y-%m-%d %H:%M:%S")); m_nBufferLength = m_strDateValue.Length(); }
wxString CTimeFormat::FormatDate(const wxDateTime &time) { Impl& impl = GetImpl(); return time.Format(impl.m_dateFormat); }
void RevTooltip::SetDocument(const doc_id& di, wxPoint pos) { Hide(); cxLOCK_READ(m_catalyst) wxASSERT(catalyst.IsOk(di)); m_docId = di; // Set the user info const unsigned int userId = catalyst.GetDocAuthor(m_docId); m_userPic->SetBitmap(catalyst.GetUserPic(userId)); m_userName->SetLabel(catalyst.GetUserName(userId)); if (userId == 0) m_userColor->Hide(); else { m_userColor->SetBackgroundColour(catalyst.GetUserColor(userId)); m_userColor->Show(); } // Set the Label wxString label = catalyst.GetLabel(m_docId); if (!label.empty()) label += wxT(":"); m_labelCtrl->SetLabel(label); // Set the Date const wxDateTime date = catalyst.GetDocDate(m_docId); const wxString age = catalyst.GetDocAge(m_docId); const wxString longdate = date.Format(wxT("%A, %B %d, %Y - %X ")) + wxString::Format(wxT("(%s)"),age.c_str()); m_dateCtrl->SetLabel(longdate); // Set the Comment m_descCtrl->SetLabel(catalyst.GetDescription(m_docId)); // Show paths to mirrors (if available) if (catalyst.IsMirrored(di)) { m_mainSizer->Show(m_mirrorSizer, true, true); wxArrayString paths; if (di.IsDraft()) catalyst.GetMirrorPathsForDraft(di, paths); // gets mirrors for all draft revisions else catalyst.GetMirrorPaths(di, paths); if (!paths.IsEmpty()) { wxString tip = paths[0]; for (size_t i = 1; i < paths.GetCount(); ++i) { tip += wxT("\n"); tip += paths[i]; } m_mirrorlistCtrl->SetLabel(tip); } else wxASSERT(false); } else m_mainSizer->Show(m_mirrorSizer, false, true); cxENDLOCK m_mainSizer->Layout(); m_mainSizer->SetSizeHints(m_mainPanel); m_mainSizer->SetSizeHints(this); // Get the size of the screen const int screen_x = wxSystemSettings::GetMetric(wxSYS_SCREEN_X); const int screen_y = wxSystemSettings::GetMetric(wxSYS_SCREEN_Y); // Get the size of the mouse cursor // BUG WORKAROUND: GetMetric gives how large it _can_ be (32*32) not // how large the actual visible image is. const int cursor_x = 16; // wxSystemSettings::GetMetric(wxSYS_CURSOR_X); const int cursor_y = 17; // wxSystemSettings::GetMetric(wxSYS_CURSOR_Y); const wxSize size = GetSize(); // Calculate the correct placement // (pos is assumed to be upper left corner of cursor) if (pos.x + cursor_x + size.x > screen_x) pos.x -= size.x + 3; else pos.x += cursor_x; if (pos.y + cursor_y + size.y > screen_y) pos.y -= size.y + 3; else pos.y += cursor_y; Move(pos); Show(); }
/// Formats a wxDateTime value using the long format representation of the /// user's locale /// @param dateTime wxDateTime value to format /// @return Formatted string wxString wxGetLocaleLongDateTime(const wxDateTime& dateTime) { //------Last Verified------// // - Nov 29, 2004 return (dateTime.Format(wxT("%#c"))); }
void print_time(const wxDateTime &s) { wxLogWarning(_T("%s"), s.Format().c_str()); }
wxString nwxString::FormatDateTimeXML(const wxDateTime &dt) { // works in UTC only return dt.Format(TIME_FORMAT_XML,wxDateTime::GMT0); }
int date2int(wxDateTime in) { return wxAtoi(in.Format("%Y%m%d")); }