Example #1
0
void CWriteLog::Write_Log(unsigned int uiLogType, TCHAR* pStrModel, char* pStrFile, unsigned int iLine, TCHAR *pstrFmt, ...)
{
#if _LOG_WRITE_STATE_   /* 写日志与否的编译开关*/

	LOG_DATA data;

	time_t curTime;
	struct tm *mt;
	va_list v1;
	memset(&data, 0, sizeof(LOG_DATA));
	va_start(v1, pstrFmt);
	_vsntprintf(data.strText, MAX_LOGTEXT_LEN, pstrFmt, v1);
	va_end(v1);
	data.iType = uiLogType;
	curTime = time(NULL);
	mt = localtime(&curTime);
	_tcsftime(data.strDate, sizeof(data.strDate), _T("%Y-%m-%d"), mt);
	_tcsftime(data.strTime, sizeof(data.strTime), _T("%H:%M:%S"), mt);

	_tcscat(data.strModel, pStrModel);

	//转成TCHAR
	int len = strlen(pStrFile);
	wchar_t * pUnicode = new  wchar_t[ len + 1];  
	memset(pUnicode,0,(len +1)*sizeof(wchar_t));  
	::MultiByteToWideChar( CP_ACP, 0, pStrFile, -1, (LPWSTR)pUnicode, len );  
	_tcscat(data.strFile, pUnicode);
	delete[] pUnicode;
	pUnicode = NULL;

	data.iLine = iLine;

	Write_Log_Text(&data);
#endif _LOG_WRITE_STATE_
}
Example #2
0
static TCHAR *writets (void)
{
	struct tm *t;
	struct _timeb tb;
	static TCHAR out[100];
	TCHAR *p;
	static TCHAR lastts[100];
	TCHAR curts[100];

	if (bootlogmode)
		return NULL;
	if (nodatestamps)
		return NULL;
	_ftime (&tb);
	t = localtime (&tb.time);
	_tcsftime (curts, sizeof curts / sizeof (TCHAR), _T("%Y-%m-%d %H:%M:%S\n"), t);
	p = out;
	*p = 0;
	if (_tcsncmp (curts, lastts, _tcslen (curts) - 3)) { // "xx\n"
		_tcscat (p, curts);
		p += _tcslen (p);
		_tcscpy (lastts, curts);
	}
	_tcsftime (p, sizeof out / sizeof (TCHAR) - (p - out) , _T("%S-"), t);
	p += _tcslen (p);
	_stprintf (p, _T("%03d"), tb.millitm);
	p += _tcslen (p);
	if (vsync_counter != 0xffffffff)
		_stprintf (p, _T(" [%d %03d%s%03d]"), vsync_counter, current_hpos (), lof_store ? _T("-") : _T("="), vpos);
	_tcscat (p, _T(": "));
	return out;
}
Example #3
0
void CALLBACK TimerProc(HWND, UINT, UINT_PTR, DWORD)
{
	for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
		char *proto = GetContactProto(hContact);
		if (proto && (db_get_b(hContact, proto, "ChatRoom", 0) == 0) && (CallProtoService(proto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_IMSEND) && isContactGoneFor(hContact, options.iAbsencePeriod2) && (db_get_b(hContact, MODULE_NAME, "StillAbsentNotified", 0) == 0))
		{
			db_set_b(hContact, MODULE_NAME, "StillAbsentNotified", 1);
			SkinPlaySound("buddyExpectatorStillAbsent");

			TCHAR* message = TranslateT("has not returned after a long absence.");
			time_t tmpTime;
			TCHAR tmpBuf[251] = { 0 };
			tmpTime = getLastSeen(hContact);
			if (tmpTime != -1)
			{
				_tcsftime(tmpBuf, 250, TranslateT("has not returned after being absent since %#x"), gmtime(&tmpTime));
				message = tmpBuf;
			}
			else
			{
				tmpTime = getLastInputMsg(hContact);
				if (tmpTime != -1)
				{
					_tcsftime(tmpBuf, 250, TranslateT("has not returned after being absent since %#x"), gmtime(&tmpTime));
					message = tmpBuf;
				}
			}

			GoneNotify(hContact, message);
		}
	}
}
Example #4
0
void CWriteLog::Write_Log(unsigned int uiLogType, TCHAR* pStrModel, TCHAR* pStrFile, unsigned int iLine, TCHAR *pstrFmt, ...)
{
#if _LOG_WRITE_STATE_   /* 写日志与否的编译开关*/

	LOG_DATA data;

	time_t curTime;
	struct tm *mt;
	va_list v1;
	memset(&data, 0, sizeof(LOG_DATA));
	va_start(v1, pstrFmt);
	_vsntprintf(data.strText, MAX_LOGTEXT_LEN, pstrFmt, v1);
	va_end(v1);
	data.iType = uiLogType;
	curTime = time(NULL);
	mt = localtime(&curTime);
	_tcsftime(data.strDate, sizeof(data.strDate), _T("%Y-%m-%d"), mt);
	_tcsftime(data.strTime, sizeof(data.strTime), _T("%H:%M:%S"), mt);

	_tcscat(data.strModel, pStrModel);
	_tcscat(data.strFile, pStrFile);
	data.iLine = iLine;
	
	Write_Log_Text(&data);
#endif _LOG_WRITE_STATE_
}
   _bstr_t DateTimeSpan::Format(LPCTSTR pFormat) const
   {
      _bstr_t strSpan;
      struct tm tmTemp;

      // If null, return empty string
      if (GetStatus() == null)
         return strSpan;

      // If invalid, return DateTimeSpan resource string
      if (GetStatus() == invalid || !TmFromOleDate(span_, tmTemp))
      {
         //VERIFY(strSpan.LoadString(AFX_IDS_INVALID_DATETIMESPAN));
         return strSpan;
      }

      // Convert tm from afx internal format to standard format
      TmConvertToStandardFormat(tmTemp);

      // Fill in the buffer, disregard return value as it's not necessary
      LPTSTR lpszTemp = new TCHAR[MAX_TIME_BUFFER_SIZE];
      _tcsftime(lpszTemp, MAX_TIME_BUFFER_SIZE, pFormat, &tmTemp);
      strSpan=lpszTemp;
      delete [] lpszTemp;

      return strSpan;
   }
Example #6
0
void RichEditEventLogger::AddToLog(LogLevel level, const TCHAR * msg, ...)
{
	TCHAR * pLogMsg = logMsgBuffer;
	time_t rawtime;
	struct tm timeinfo;
	va_list argptr;

	if ((m_Logger == NULL) || (level < m_LogLevel))
	{
		return;
	}

	time(&rawtime);
	localtime_s(&timeinfo, &rawtime);

	_tcsftime(pLogMsg, MAX_LOG_MSG_LENGTH, _T("%d-%m-%Y %I:%M:%S: "), &timeinfo);
	pLogMsg += _tcslen(logMsgBuffer);

	va_start(argptr, msg);
	_vstprintf_s(pLogMsg, MAX_LOG_MSG_LENGTH - _tcslen(logMsgBuffer), msg, argptr);
	va_end(argptr);

	m_Logger->SetSel(-1, -1);
	m_Logger->ReplaceSel(logMsgBuffer);
	m_Logger->PostMessage(WM_VSCROLL, SB_BOTTOM, NULL);
}
Example #7
0
void Log::tprint(int level, LPCTSTR fmt, ...)
{
    if (level > sizeof(gsLogLabels)/sizeof(char *) - 1)
    {
        return;
    }

    if (level > m_loglevel)
    {
        return;
    }
    va_list list; 
    va_start(list, fmt);
    TCHAR szTime[MAX_PATH];
    time_t now = time(NULL);
    _tcsftime(szTime, MAX_PATH, _T("%c"), localtime(&now));

    ::EnterCriticalSection(&m_lock);
    if(m_log_fp) {
        _ftprintf(m_log_fp, _T("[%s]"), szTime); 
        _vftprintf(m_log_fp, fmt, list);
        fflush(m_log_fp);
    }
    ::LeaveCriticalSection(&m_lock);
    va_end(list);
    return;
}
Example #8
0
TCHAR* MakeTimeStamp(TCHAR *pszStamp, time_t time)
{
	static TCHAR szTime[30];
	if (!_tcsftime(szTime, _countof(szTime)-1, pszStamp, localtime(&time)))
		_tcsncpy_s(szTime, TranslateT("<invalid>"), _TRUNCATE);
	return szTime;
}
Example #9
0
void AddEventsDefault(HWND hWnd, int renderer, TCHAR *filter, SIG_MATCHESFILTER MatchesFilter)
{
	HWND hHistoryList = GetDlgItem(hWnd, IDC_LST_HISTORY);
	TCHAR buffer[1024];
	struct tm *myTime;
	
	LVITEM item = {0};
	item.mask = LVIF_TEXT;

	int i, lIndex;
	lIndex = 0;
	PopupHistoryData *popupItem;
	for (i = 0; i < lstPopupHistory.Count(); i++)
	{
		item.iItem = lIndex;
		popupItem = lstPopupHistory.Get(i);
		if (MatchesFilter(filter, popupItem))
		{
			item.pszText = popupItem->titleT;
			ListView_InsertItem(hHistoryList, &item);
			ListView_SetItemText(hHistoryList, lIndex, 1, popupItem->messageT);
			myTime = localtime(&popupItem->timestamp);
			_tcsftime(buffer, 1024, _T("%c"), myTime);
			ListView_SetItemText(hHistoryList, lIndex++, 2, buffer);
		}
	}
}
Example #10
0
void SDateEdit::SetDateTime( CTime tm )
{
    TCHAR szBuf[256];
    struct tm ttm;
    _tcsftime(szBuf,256,_T("%Y/%m/%d"),tm.GetLocalTm(&ttm));
    SetDateTime(szBuf);
}
Example #11
0
/**
 * Sets statusbar text of hContact with last read time (from facy.readers map)
 */
void FacebookProto::MessageRead(MCONTACT hContact)
{
	/*std::map<MCONTACT, time_t>::iterator it = facy.readers.find(hContact);
	if (it == facy.readers.end())
	return;*/

	// We may use this instead of checing map as we have this info already in memory (this value is resident)
	time_t time = getDword(hContact, FACEBOOK_KEY_MESSAGE_READ, 0);
	if (!time)
		return;

	TCHAR ttime[64];
	_tcsftime(ttime, _countof(ttime), _T("%X"), localtime(&time));

	StatusTextData st = { 0 };
	st.cbSize = sizeof(st);
	st.hIcon = IcoLib_GetIconByHandle(GetIconHandle("read"));

	if (isChatRoom(hContact)) {
		// Load readers names
		ptrT treaders(getTStringA(hContact, FACEBOOK_KEY_MESSAGE_READERS));
		mir_sntprintf(st.tszText, TranslateT("Message read: %s by %s"), ttime, treaders ? treaders : _T("???"));
		CallService(MS_MSG_SETSTATUSTEXT, (WPARAM)hContact, (LPARAM)&st);
	} else if (!ServiceExists(MS_MESSAGESTATE_UPDATE)){
		mir_sntprintf(st.tszText, TranslateT("Message read: %s"), ttime);
		CallService(MS_MSG_SETSTATUSTEXT, (WPARAM)hContact, (LPARAM)&st);
	}
}
Example #12
0
//不包括扩展名
const std::wstring GenerateNewFilePath(DWORD dwPID)
{
	TCHAR szPath[_MAX_PATH] = {0};
	

	TCHAR szDir[_MAX_PATH] = {0};
	_tcscpy_s(szDir, crash::GetCrashPath());

	TCHAR szDate[128] = {0};
	time_t curTime = time(NULL);
	_tcsftime(szDate, _countof(szDate) - 1, _T("%Y-%m-%d"), localtime(&curTime));

	int i = 0;
	for (;;)
	{
		TCHAR szTemp[_MAX_PATH] = {0};
		_sntprintf_s(szTemp, _countof(szTemp), _TRUNCATE, _T("%s%s crash %u_%u.*"), szDir, szDate, dwPID, i);
		
		WIN32_FIND_DATA findFileData = {0};
		HANDLE hFind = ::FindFirstFile(szTemp, &findFileData);
		if (hFind == INVALID_HANDLE_VALUE) 
		{
			_sntprintf_s(szPath, _countof(szPath), _TRUNCATE, _T("%s%s crash %u_%u"), szDir, szDate, dwPID, i);
			break;
		} 
		::FindClose(hFind);
		++i;
	}

	return szPath;
}
Example #13
0
void CLog::StartNewLogFile()
{
	time_t tStarted = m_tStarted;
	Close();

	TCHAR szDateLogStarted[40];
	_tcsftime(szDateLogStarted, ARRSIZE(szDateLogStarted), _T("%Y.%m.%d %H.%M.%S"), localtime(&tStarted));

	TCHAR szDrv[_MAX_DRIVE];
	TCHAR szDir[_MAX_DIR];
	TCHAR szNam[_MAX_FNAME];
	TCHAR szExt[_MAX_EXT];
	_tsplitpath(m_strFilePath, szDrv, szDir, szNam, szExt);

	CString strLogBakNam;
	strLogBakNam = szNam;
	strLogBakNam += _T(" - ");
	strLogBakNam += szDateLogStarted;

	TCHAR szLogBakFilePath[MAX_PATH];
	_tmakepath(szLogBakFilePath, szDrv, szDir, strLogBakNam, szExt);

	if (_trename(m_strFilePath, szLogBakFilePath) != 0)
		_tremove(m_strFilePath);

	Open();
}
Example #14
0
TCHAR* timestamp( TCHAR* dateTimeStr ) {
 time_t dateTime; 
 time( &dateTime );
 _tcsftime( dateTimeStr, BUF_LEN, _T("---%Y-%m-%d--%H-%M-%S"),
  localtime( &dateTime ));
 return dateTimeStr;
}
Example #15
0
int MatchesFilterCI(const TCHAR *filterS, const PopupHistoryData *popupItem)
{
	if (_tcslen(filterS) <= 0)	{ return 1;	} //if no filter is set then the popup item matches the filter
	int match = 0;
	const int BUFFER_SIZE = 1024;
	TCHAR buffer[BUFFER_SIZE];
	TCHAR filterI[BUFFER_SIZE];
	
	ConvertCase(filterI, filterS, BUFFER_SIZE);
	
	ConvertCase(buffer, popupItem->messageT, BUFFER_SIZE); //check message part
	match = (_tcsstr(buffer, filterI)) ? 1 : match;
	
	if (!match) // check title part of no match has been found
	{
		ConvertCase(buffer, popupItem->titleT, BUFFER_SIZE);
		match = (_tcsstr(buffer, filterI)) ? 1 : match;
	}
	
	if (!match) //if no match has been found yet try to match the timestamp
	{
		struct tm *myTime = localtime(&popupItem->timestamp);
		_tcsftime(buffer, 1024, _T("%c"), myTime);
		match = (_tcsstr(buffer, filterI)) ? 1 : match;
	}
	
	return match;
}
Example #16
0
void COScopeCtrl::OnMouseMove(UINT nFlags, CPoint point)
{
	CWnd::OnMouseMove(nFlags, point);

	if ((nFlags & MK_LBUTTON) == 0) {
		if (m_uLastMouseFlags & MK_LBUTTON) {
			// Mouse button was released -> explicitly clear the tooltip.
			CWnd* pwndParent = GetParent();
			if (pwndParent)
				pwndParent->SendMessage(UM_OSCOPEPOSITION, 0, (LPARAM)(LPCTSTR)_T(""));
		}
		m_uLastMouseFlags = nFlags;
		return;
	}
	m_uLastMouseFlags = nFlags;

	// If that check is not there, it may lead to 100% CPU usage because Windows (Vista?)
	// keeps sending mouse messages even if the mouse does not move but when the mouse
	// button stays pressed.
	if (point == m_ptLastMousePos)
		return;
	m_ptLastMousePos = point;

	CRect plotRect;
	GetPlotRect(plotRect);
	if (!plotRect.PtInRect(point))
		return;

	CWnd* pwndParent = GetParent();
	if (pwndParent)
	{
		int yValue = -1;
		int plotHeight = plotRect.Height();
		if (plotHeight > 0) {
			int yPixel = plotHeight - (point.y - plotRect.top);
			yValue = (int)(m_PlotData[0].dLowerLimit + yPixel * m_PlotData[0].dRange / plotHeight);
		}

		int mypos = (plotRect.Width() - point.x) + plotRect.left;
		int shownsecs = plotRect.Width() * thePrefs.GetTrafficOMeterInterval();
		float apixel = (float)shownsecs / (float)plotRect.Width();

		CString strInfo;
		//Xman Maella Statistik-Zoom
		//zz_fly :: moved from CStatisticsDlg::OnOscopePositionMsg()
		/*
		DWORD dwTime = (DWORD)(mypos * apixel);
		*/
		DWORD dwTime = (DWORD)(mypos * apixel) / thePrefs.GetZoomFactor(); 
		//Xman end
		time_t tNow = time(NULL) - dwTime;
		TCHAR szDate[128];
		_tcsftime(szDate, _countof(szDate), thePrefs.GetDateTimeFormat4Log(), localtime(&tNow));
		strInfo.Format(_T("%s: %u @ %s ") + GetResString(IDS_TIMEBEFORE), m_str.YUnits, yValue, szDate, CastSecondsToLngHM(dwTime));

		pwndParent->SendMessage(UM_OSCOPEPOSITION, 0, (LPARAM)(LPCTSTR)strInfo);
	}
}
void CMediaWin::UpdatePlayingProgress()
{
	CDuiString  strTime;
	struct tm   tmCurrent,tmTotal;
	time_t      timeCurrent = thePlayer->GetTime() / 1000;
	time_t      timeTotal   = thePlayer->GetTotalTime() / 1000;
	TCHAR       szCurrent[MAX_PATH],szTotal[MAX_PATH];

	gmtime_s(&tmCurrent, &timeCurrent);
	gmtime_s(&tmTotal, &timeTotal);

	_tcsftime(szCurrent, MAX_PATH, _T("%X"), &tmCurrent);
	_tcsftime(szTotal,   MAX_PATH, _T("%X"), &tmTotal);
	strTime.Format(_T("%s/%s"), szCurrent,szTotal);

	SetTimeText(strTime);
	SetProgress(thePlayer->GetPos(),true);
}
Example #18
0
LRESULT CDuiFrameWnd::OnPosChanged(HWND hwnd, WPARAM wParam, LPARAM lParam )
{
    CDuiString  strTime;
    struct tm   tmTotal, tmCurrent;
    time_t      timeTotal   = m_cAVPlayer.GetTotalTime() / 1000;
    time_t      timeCurrent = m_cAVPlayer.GetTime() / 1000;
    TCHAR       szTotal[MAX_PATH], szCurrent[MAX_PATH];

    gmtime_s(&tmTotal, &timeTotal);
    gmtime_s(&tmCurrent, &timeCurrent);
    _tcsftime(szTotal,   MAX_PATH, _T("%X"), &tmTotal);
    _tcsftime(szCurrent, MAX_PATH, _T("%X"), &tmCurrent);
    strTime.Format(_T("%s / %s"), szCurrent, szTotal);

    m_pLabelTime->SetText(strTime);
    m_pSliderPlay->SetValue(m_cAVPlayer.GetPos());
    return TRUE;
}
Example #19
0
CString CSPTime::FormatGmt(LPCTSTR pFormat) const
{
	TCHAR szBuffer[maxTimeBufferSize];

	struct tm* ptmTemp = gmtime(&m_time);
	if (ptmTemp == NULL ||
		!_tcsftime(szBuffer, sizeof(szBuffer), pFormat, ptmTemp))
		szBuffer[0] = '\0';
	return szBuffer;
}
Example #20
0
void COutputPage::AddLogMsg(LPCTSTR psz)
{
    CString str;
    time_t ltime;
    time(&ltime);
    _tcsftime(str.GetBuffer(80),80,_T("*** %H:%M:%S "),localtime(&ltime));
    str.ReleaseBuffer();
    str+=psz;
    str+=_T("\r\n");
    AddText(str);
}
Example #21
0
// _T("%Y-%m-%d %H:%M:%S")
const TCHAR * FormatTime(time_t lTime, LPCTSTR lpFmt)
{
	struct tm * lpTimeInfo;
	static TCHAR cTime[32];

	memset(cTime, 0, sizeof(cTime));

	lpTimeInfo = localtime(&lTime);
	if (lpTimeInfo != NULL)
		_tcsftime(cTime, sizeof(cTime) / sizeof(TCHAR), lpFmt, lpTimeInfo);
	return cTime;
}
Example #22
0
 LPCTSTR CreateTimeStamp(LPTSTR lpBuffer, size_t iBufferSize)
 {
       struct _timeb tb;
       _ftime(&tb);
       size_t len = _tcsftime(lpBuffer, iBufferSize, _T("%b %d %H:%M:%S"), localtime(&tb.time));
       if (len && len+4 < iBufferSize) {
           if (_sntprintf(lpBuffer+len, iBufferSize-len-1, _T(".%03d"), tb.millitm) < 0) {
                lpBuffer[iBufferSize-len-1] = 0;
           }
       }
       return lpBuffer;
 }
KString KString::CurrentDateString()
{
	time_t long_time;

	time(&long_time);

	TCHAR Buf[128];
	_tcsftime(	Buf,
				sizeof(Buf) - 1,
				TEXT("%Y-%m-%d"),
				localtime(&long_time));

	return Buf;
}
KString KString::CurrentTimeString()
{
	time_t long_time;

	time(&long_time);

	TCHAR Buf[128];

	_tcsftime(	Buf,
				sizeof(Buf) - 1,
				TEXT("%H:%M:%S"),
				localtime(&long_time));

	return Buf;
}
Example #25
0
CString FormatDateTimeEpochUTC(const Variant& value)
{
   __time64_t time = GetUnsignedIntValue(value);

   struct tm tmtime = { 0 };
   errno_t err = ::_localtime64_s(&tmtime, &time);
   if (err != 0)
      return _T("invalid date/time");

   CString cszText;
   _tcsftime(cszText.GetBuffer(32), 32, _T("%Y-%m-%d %H:%M:%S"), &tmtime);
   cszText.ReleaseBuffer();

   return cszText;
}
Example #26
0
/**
 * Sets statusbar text of hContact with last read time (from facy.readers map)
 */
void FacebookProto::MessageRead(MCONTACT hContact)
{
	std::map<MCONTACT, time_t>::iterator it = facy.readers.find(hContact);
	if (it == facy.readers.end())
		return;
	
	TCHAR ttime[64];
	_tcsftime(ttime, SIZEOF(ttime), _T("%X"), localtime(&it->second));

	StatusTextData st = { 0 };
	st.cbSize = sizeof(st);
	st.hIcon = Skin_GetIconByHandle(GetIconHandle("read"));
	mir_sntprintf(st.tszText, SIZEOF(st.tszText), TranslateT("Message read: %s"), ttime);
	
	CallService(MS_MSG_SETSTATUSTEXT, (WPARAM)hContact, (LPARAM)&st);
}
Example #27
0
void RichEditEventLogger::AddToLog(LogLevel level, uint8_t * data, int32_t length, const TCHAR * msg, ...)
{
	if (level < m_LogLevel)
	{
		return;
	}

	TCHAR * pLogMsg = logMsgBuffer;
	time_t rawtime;
	struct tm timeinfo;

	time(&rawtime);
	localtime_s(&timeinfo, &rawtime);

	_tcsftime(pLogMsg, MAX_LOG_MSG_LENGTH, _T("%d-%m-%Y %I:%M:%S: "), &timeinfo);
	pLogMsg += _tcslen(logMsgBuffer);

	va_list argptr;
	va_start(argptr, msg);
	_vstprintf_s(pLogMsg, MAX_LOG_MSG_LENGTH - _tcslen(logMsgBuffer), msg, argptr);
	va_end(argptr);

	int32_t logMsgLength = sizeof(logMsgBuffer) / sizeof(TCHAR);
	int32_t currentLength = _tcslen(logMsgBuffer);

	TCHAR hexStr[16];
	for (int32_t i = 0; i < length; i++)
	{
		if ((i % 16) == 0)
		{
			_tcscat_s(logMsgBuffer, logMsgLength - currentLength, _T("\n"));
			currentLength = _tcslen(logMsgBuffer);
			pLogMsg = logMsgBuffer + currentLength;
		}
		_stprintf_s(hexStr, sizeof(hexStr) / sizeof(TCHAR), _T(" %02X"), data[i]);
		_tcscat_s(pLogMsg, logMsgLength - currentLength, hexStr);
		currentLength += _tcslen(hexStr);
		pLogMsg = logMsgBuffer + currentLength;
	}
	_tcscat_s(pLogMsg, logMsgLength - currentLength, _T("\n"));

	m_Logger->SetSel(-1, -1);
	m_Logger->ReplaceSel(logMsgBuffer);
	m_Logger->PostMessage(WM_VSCROLL, SB_BOTTOM, NULL);
}
CString TimeSpan::FormatISO8601() const throw()
{
   ATLASSERT(m_spImpl != NULL);

   if (m_spImpl->m_span.is_not_a_date_time())
      return _T("");

   CString cszFormat(_T("P%H:%M:%S"));

   struct tm tmTemp = boost::posix_time::to_tm(m_spImpl->m_span);

   CString cszDateTime;
   LPTSTR pszBuffer = cszDateTime.GetBufferSetLength(256);
   _tcsftime(pszBuffer, cszDateTime.GetLength(), cszFormat, &tmTemp);
   cszDateTime.ReleaseBuffer();

   return cszDateTime;
}
Example #29
0
String Time::Format (const TCHAR* formatter) const
{
	TCHAR buffer[200];

	struct tm convertedTime;
	::memset(&convertedTime, 0, sizeof(convertedTime));

	convertedTime.tm_year = m_Time.wYear - 1900;
	convertedTime.tm_mon = m_Time.wMonth - 1;
	convertedTime.tm_mday = m_Time.wDay;
	convertedTime.tm_hour = m_Time.wHour;
	convertedTime.tm_min = m_Time.wMinute;
	convertedTime.tm_sec = m_Time.wSecond;

	_tcsftime (buffer, sizeof (buffer), formatter, &convertedTime);

	return (String(buffer));
}
CString DateTime::Format(const CString& cszFormat, const TimeZone& tz) const throw()
{
   ATLASSERT(m_spImpl != NULL);

   if (m_spImpl->m_dt.is_not_a_date_time())
      return _T("");

   // calculate offset to UTC
   TimeSpan tsTimezone = tz.GetUtcOffset(*this);

   struct tm tmTemp = boost::posix_time::to_tm(m_spImpl->m_dt + tsTimezone.m_spImpl->m_span);

   CString cszDateTime;
   LPTSTR pszBuffer = cszDateTime.GetBufferSetLength(256);
   _tcsftime(pszBuffer, cszDateTime.GetLength(), cszFormat, &tmTemp);
   cszDateTime.ReleaseBuffer();

   return cszDateTime;
}