wxString CSizeFormatBase::FormatNumber(COptionsBase* pOptions, const wxLongLong& size, bool* thousands_separator /*=0*/)
{
	if ((thousands_separator && !*thousands_separator) || pOptions->GetOptionVal(OPTION_SIZE_USETHOUSANDSEP) == 0)
		return size.ToString();

	const wxString& sep = GetThousandsSeparator();
	if (sep.empty())
		return size.ToString();

	wxString tmp = size.ToString();
	const int len = tmp.Len();
	if (len <= 3)
		return tmp;

	wxString result;
	int i = (len - 1) % 3 + 1;
	result = tmp.Left(i);
	while (i < len)
	{
		result += sep + tmp.Mid(i, 3);
		i += 3;
	}

	return result;
}
Example #2
0
wxString ElapsedTimeToStr(wxLongLong msec)
{
	wxTimeSpan tsMsec(0, 0, 0, msec);

	int days = tsMsec.GetDays();
	int hours = (wxTimeSpan(tsMsec.GetHours(), 0, 0, 0) - wxTimeSpan(days * 24)).GetHours();
	int minutes = (wxTimeSpan(0, tsMsec.GetMinutes(), 0, 0) - wxTimeSpan(hours)).GetMinutes();
	long seconds = (wxTimeSpan(0, 0, tsMsec.GetSeconds(), 0) - wxTimeSpan(0, minutes)).GetSeconds().ToLong();
	long milliseconds = (wxTimeSpan(0, 0, 0, tsMsec.GetMilliseconds()) - wxTimeSpan(0, 0, seconds)).GetMilliseconds().ToLong();

	if (days > 0)
		return wxString::Format(
		           wxT("%d %s, %02d:%02d:%02ld hours"),
		           days, wxT("days"), hours, minutes, seconds
		       );
	else if (hours > 0)
		return wxString::Format(
		           wxT("%02d:%02d:%02ld hours"), hours, minutes, seconds
		       );
	else if (msec >= 1000 * 60)
		return wxString::Format(wxT("%02d:%02ld minutes"), minutes, seconds);
	else if (msec >= 1000)
		return wxString::Format(
		           wxT("%ld.%ld secs"), seconds, milliseconds / 100
		       );
	else
		return msec.ToString() + wxT(" msec");
}
Example #3
0
 virtual void UpdateCallback(wxUpdateType type,
                             const wxString& database, const wxString& table,
                             wxLongLong rowid)
 {
   const char* strType;
   cout << "Here is the UPDATE callback" << endl;
   switch (type)
   {
     case SQLITE_DELETE:
       strType = "DELETE row ";
       break;
     case SQLITE_INSERT:
       strType = "INSERT row ";
       break;
     case SQLITE_UPDATE:
       strType = "UPDATE row ";
       break;
     default:
       strType = "Unknown change row ";
       break;
   }
   cout << strType << (const char*) rowid.ToString().mb_str()
        << " in table " << (const char*) table.mb_str()
        << " of database " << (const char*) database.mb_str() << endl;
 }
Example #4
0
wxLongLong TIniFile::ReadLongLong(const wxString &Section, const wxString &Ident,
	wxLongLong Default)
{
	wxString str = ReadString(Section, Ident, Default.ToString());
	wxLongLong lng = StrToLongLong(str);
	return lng;
}
void ServerEvents::OnPong(wxLongLong ping_time)
{
	//wxLongLong is non-POD and cannot be passed to wxString::Format as such. use c-string rep instead. converting to long might loose precision
	UiEvents::StatusData data(wxString::Format(_("ping: %s ms"), ping_time.ToString().c_str()), 2);
	UiEvents::GetStatusEventSender(UiEvents::addStatusMessage).SendEvent(data);
}
Example #6
0
void TIniFile::WriteLongLong(const wxString &Section, const wxString &Ident,
	wxLongLong Value)
{
	WriteString(Section, Ident, Value.ToString());
}