本文整理汇总了C++中wxDateTime::Format方法的典型用法代码示例。如果您正苦于以下问题:C++ wxDateTime::Format方法的具体用法?C++ wxDateTime::Format怎么用?C++ wxDateTime::Format使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wxDateTime
的用法示例。
在下文中一共展示了wxDateTime::Format方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Run
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;
}
示例2: FormatDateLong
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
}
示例3: GetDistance
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;
}
}
示例4: SetParamDate
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);
}
示例5: GetSpanLabel
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());
}
}
示例6: MakeDateTimeLabel
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;
}
示例7: FormatDateTime
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;
}
示例8: Run
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;
}
示例9: GetDisplayDate
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();
}
示例10: AddEntry
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);
}
示例11: if
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;
}
示例12: timestamp2s
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);
}
示例13: Advise
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);
}
}
示例14: SetParamDate
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();
}
}
}
}
示例15: wxGetLocaleShortDateTime
/// 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());
}