本文整理汇总了C++中CTime::GetTime方法的典型用法代码示例。如果您正苦于以下问题:C++ CTime::GetTime方法的具体用法?C++ CTime::GetTime怎么用?C++ CTime::GetTime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CTime
的用法示例。
在下文中一共展示了CTime::GetTime方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: NewGroupID
long NewGroupID(int parentID, CString text)
{
long lID=0;
CTime time;
time = CTime::GetCurrentTime();
try
{
//sqlite doesn't like single quotes ' replace them with double ''
if(text.IsEmpty())
text = time.Format("NewGroup %y/%m/%d %H:%M:%S");
text.Replace(_T("'"), _T("''"));
CString cs;
cs.Format(_T("insert into Main (lDate, mText, lDontAutoDelete, bIsGroup, lParentID) values(%d, '%s', %d, 1, %d);"),
(long)time.GetTime(),
text,
(long)time.GetTime(),
parentID);
theApp.m_db.execDML(cs);
lID = (long)theApp.m_db.lastRowId();
}
CATCH_SQLITE_EXCEPTION_AND_RETURN(0)
return lID;
}
示例2: SetLocalTime
bool CTime::SetLocalTime(const CTime &time_to_set)
{
#ifdef WIN32
int tmp_time = time_to_set.GetTime();
struct tm *tmp_tm = CTime::EibTime(&tmp_time);
if (!tmp_tm)
return false;
SYSTEMTIME systemTime;
systemTime.wDay = tmp_tm->tm_mday;
systemTime.wMonth = tmp_tm->tm_mon + 1;
systemTime.wYear = tmp_tm->tm_year + 1900;
systemTime.wHour = tmp_tm->tm_hour;
systemTime.wMinute = tmp_tm->tm_min;
systemTime.wSecond = tmp_tm->tm_sec;
systemTime.wMilliseconds = 0;
if (!::SetLocalTime(&systemTime))
return false;
return true;
#else
struct timeval tv = { (int)(time_to_set.GetTime()), 0 };
if (settimeofday(&tv, NULL) < 0) {
perror("settimeofday");
return false;
}
return true;
#endif
}
示例3: OnBnClickedOk
void CDlgUserManager::OnBnClickedOk()
{
// TODO: 在此添加控件通知处理程序代码
//OnOK();
UpdateData();
if ( m_strEditUserName.IsEmpty() ) { AfxMessageBox(_T("用户名不能空")); return;}
else if( m_strEditPwd.IsEmpty() ) { AfxMessageBox(_T("密码不能空")); return;}
tagAddUpdateUserInfo user;ZeroMemory(&user,sizeof(user));
_tcscpy( user.szUserName,m_strEditUserName);
_tcscpy( user.szPassWord,m_strEditPwd);
_tcscpy( user.szCompanyName,m_strEditCompany);
// COleDateTime ot;
// ot.ParseDateTime(m_strEditRegTime);
CTime ct;
m_regTime.GetTime(ct);
user.nRegTimeStamp = ct.GetTime();
m_expireDate.GetTime(ct);
user.nExpireTimeStamp = ct.GetTime();
user.byPower = m_comPower.GetCurSel();
g_LogicClient.AddUpdateUserInfo(user);
}
示例4: tmNow
int XgnExtDataDlg::Transfer5MinTimet(int tmIn)
{
CTime tmNow (tmIn);
CTime tmb (tmNow.GetYear (),tmNow.GetMonth (),tmNow.GetDay (),9,35,0);
if(tmNow<tmb)
return (int)tmb.GetTime ();
CTimeSpan sp = tmNow-tmb;
int nMinute = sp.GetMinutes ();
int nRtn = nMinute%5==0?(nMinute/5):(nMinute/5+1);
nRtn = nRtn*5*60 + tmb.GetTime ();
return nRtn;
}
示例5: OnBnClickedStartQuery
void CDlgFilterPanel::OnBnClickedStartQuery()
{
// Get CTime from 1st DataTime Control on the dialog
CTime SelTime;
this->m_CtrlDataTime.GetTime(SelTime);
// Get CTime from 2nd DataTime Control on the dialog
CTime SaleWk1;
this->m_CtrlDateTime2.GetTime(SaleWk1);
// Check user select date, must be Monday
if ( (SelTime.GetDayOfWeek() != 2) || (SaleWk1.GetDayOfWeek() != 2) )
{
::MessageBox(NULL,
"Sorry, you selected date is not Monday.\nPlease try again.",
"Warning", MB_OK | MB_ICONWARNING);
return;
}
LPMAINWORKTHREADPARAM lpThreadParam = new MAINWORKTHREADPARAM;
lpThreadParam->_StartingDate = SelTime.GetTime();
lpThreadParam->_FirstWeekSale = SaleWk1.GetTime();
CWinThread *pWinThread = AfxBeginThread(
(AFX_THREADPROC) MainWorkThreadFunc, (LPVOID) lpThreadParam,
THREAD_PRIORITY_NORMAL, 0, CREATE_SUSPENDED);
pWinThread->m_bAutoDelete = TRUE;
pWinThread->ResumeThread();
OnOK();
}
示例6: sizeof
CDumpContext& AFXAPI operator <<(CDumpContext& dc, CTime time)
{
char psz[32];
psz[0] = '\0';
__time64_t tmp = time.GetTime();
errno_t err = _ctime64_s(psz, sizeof(psz), &tmp);
if ((err != 0) || (psz[0] == '\0') || (time.GetTime() == 0))
{
return dc << "CTime(invalid #" << time.GetTime() << ")";
}
// format it
return dc << "CTime(\"" << psz << "\")";
}
示例7: Process
void CReqPlayerInfoProtocol::Process(UINT32 dwConnID)
{
CAckPlayerInfoProtocol ptcPlayerInfoAck;
ptcPlayerInfoAck.m_strName = "";
ptcPlayerInfoAck.m_iRMB = 0;
CPlayer *pPlayer = CPlayerMgr::Instance()->GetPlayerByConnID(dwConnID);
if(pPlayer!=NULL)
{
CTime tm;
tm=CTime::GetCurrentTime();
__time64_t now = tm.GetTime();
ptcPlayerInfoAck.m_TimeNow = now;
ptcPlayerInfoAck.m_strName = pPlayer->GetName();
ptcPlayerInfoAck.m_iRMB = pPlayer->GetRMB();
ptcPlayerInfoAck.m_iGold = pPlayer->GetGold();
ptcPlayerInfoAck.m_iOil = pPlayer->GetOil();
ptcPlayerInfoAck.m_iPopulation = pPlayer->GetPopulation();
ptcPlayerInfoAck.m_oBuildings = pPlayer->GetBuildingDataVec();
pPlayer->GetBuilderDataToClient(ptcPlayerInfoAck.m_oBuilderDataToClient);
pPlayer->GetLabData(ptcPlayerInfoAck.m_labdata);
pPlayer->GetSoldierData(ptcPlayerInfoAck.m_SoldierData);
pPlayer->GetCampDataToClient(ptcPlayerInfoAck.m_mapUniID2CampDataToClient);
}
CProtocolLogic * pProtocol = CProtocolLogic::GetProtocolLogic();
pProtocol->SetSendMsg(dwConnID,ptcPlayerInfoAck);
//CClientLink::Instance()->Send(dwConnID, ptcPlayerInfoAck);
}
示例8:
CArchive& AFXAPI operator <<(CArchive& ar, CTime time)
{
// This version serializes 32 bits of invalid time and after 64 bits
// time64. New code will support both 64 serialization and 32/64 deserialization.
__time64_t ttime = time.GetTime();
ar << (DWORD)cTime64Mark;
return ar << (__int64) ttime;
}
示例9: SetLocalDate
bool CTime::SetLocalDate(const CTime &into_set)
{
#ifdef WIN32
SYSTEMTIME systemTime;
int tmp_time = into_set.GetTime();
struct tm *tmp_tm = EibTime(&tmp_time);
if (!tmp_tm)
return false;
systemTime.wDay = tmp_tm->tm_mday;
systemTime.wMonth = tmp_tm->tm_mon + 1;
systemTime.wYear = tmp_tm->tm_year + 1900;
int now_t = static_cast<int>(time(0));
tmp_tm = EibTime(&now_t);
if (!tmp_tm)
return false;
systemTime.wHour = tmp_tm->tm_hour;
systemTime.wMinute = tmp_tm->tm_min;
systemTime.wSecond = tmp_tm->tm_sec;
systemTime.wMilliseconds = 0;
if (!::SetLocalTime(&systemTime))
return false;
return true;
#else
int tmp_time = into_set.GetTime();
int cur_time = time(NULL);
struct tm tmp_tm;
struct tm cur_tm;
EIBTtime_r(&tmp_time, &tmp_tm);
EIBTtime_r(&cur_time, &cur_tm);
tmp_tm.tm_sec = cur_tm.tm_sec;
tmp_tm.tm_min = cur_tm.tm_min;
tmp_tm.tm_hour = cur_tm.tm_hour;
struct timeval tv = { mktime(&tmp_tm), 0 };
if (settimeofday(&tv, NULL) < 0) {
perror("settimeofday");
return false;
}
return true;
#endif
}
示例10: GetExpireDate
//006bc220
//gObjUseImprovePotion
long CPeriodItemEx::GetExpireDate(int iDuration) //~OK
{
CTime tExpireTime;
CTime tCurrentTime(CTime::GetTickCount());
CTimeSpan tLeftTime(0,0,0,iDuration);
tExpireTime = tCurrentTime + tLeftTime;
long tReturnTime = tExpireTime.GetTime();
return tReturnTime;
}
示例11: BrowseDir
// 遍历文件以及子文件夹,这里不处理子文件夹
bool CLogMgr::BrowseDir(const TCHAR *dir,const TCHAR *filespec)
{
// 遍历文件
CFileFind logFind;
CString strDir = dir;
strDir.Format(_T("%s\\%s"), dir, filespec);
try
{
// 查找第一个文件
BOOL IsFinded=(BOOL)logFind.FindFile(strDir);
while(IsFinded)
{
IsFinded=(BOOL)logFind.FindNextFile();
if(!logFind.IsDots())
{
TCHAR foundFileName[_MAX_FILE_PATH];
memset(foundFileName, 0, _MAX_FILE_PATH);
CString strFileName = logFind.GetFileName();
T_STRNCPY(foundFileName, strFileName.GetBuffer(_MAX_FILE_PATH), (_MAX_FILE_PATH - 1));
strFileName.ReleaseBuffer();
if(logFind.IsDirectory()) // 如果是目录不处理
{
continue;
}
else // 查找到文件
{
TCHAR filename[_MAX_FILE_PATH];
memset(filename, 0x00, _MAX_FILE_PATH*sizeof(TCHAR));
T_STRCPY(filename,dir);
T_STRCAT(filename,foundFileName);
CTime lastWriteTime;
logFind.GetLastWriteTime(lastWriteTime);
if (!ProcessFile(filename, (time_t)lastWriteTime.GetTime()))
return false;
}
}
}
logFind.Close();
}
catch (...)
{
return false;
}
return true;
}
示例12: AddPoint
//.........这里部分代码省略.........
if(m_primarylegends[x].m_bIAmInUse){
n++;
z=dc.GetTextExtent(CString(m_primarylegends[x].m_szTitle));
if(z.cx > w )
w=z.cx;
// m_TextHeight = z.cy;
}
}
m_legendRect.right = m_legendRect.left + 40 + w;
m_legendRect.bottom = m_legendRect.top + 10 + (m_TextHeight*n);
}
// compute left axis area
m_axisLYRect.left = m_clientRect.left + (m_iMleft/5);
m_axisLYRect.right = m_plotRect.left;
m_axisLYRect.top = m_plotRect.top;
m_axisLYRect.bottom = m_plotRect.bottom;
// compute right axis area
m_axisRYRect.left = m_plotRect.left;
m_axisRYRect.right = m_clientRect.right - (m_iMright/5);
m_axisRYRect.top = m_plotRect.top;
m_axisRYRect.bottom = m_plotRect.bottom;
// compute bottom axis area
m_axisBXRect.left = m_plotRect.left;
m_axisBXRect.right = m_plotRect.right;
m_axisBXRect.top = m_plotRect.bottom;
m_axisBXRect.bottom = m_clientRect.bottom - (m_iMbottom/5);
// if(bInitialization)
// {
m_timeaxis.m_dSecondsPrPixel = ((double)(m_timeaxis.m_maxtime.GetTime() - m_timeaxis.m_mintime.GetTime())) / (double)m_plotRect.Width();
m_leftaxis.m_dValuePrPixel = ((double)(m_leftaxis.maxrange- m_leftaxis.minrange) / (double)m_plotRect.Height());
m_rightaxis.m_dValuePrPixel = ((double)(m_rightaxis.maxrange- m_rightaxis.minrange) / (double)m_plotRect.Height());
// }
dc.SelectObject(oFont);
}
//*******************************************************************************************************/
//* Function: clPlot::OnPaint
//*
//* Description: This function will create a memory image, call Draw to draw the plot on it, and when
//* copy the image into memory.
//*
//* This is fast and provides flicker free plot update.
//*
//* Author: Jan Vidar Berger
//*******************************************************************************************************/
void clPlot::OnPaint()
{
CPaintDC dc(this); // device context for painting
CGridMemDC pdc(&dc); // non flickering painting
Draw(&pdc);
// Do not call CWnd::OnPaint() for painting messages
}
BOOL clPlot::OnEraseBkgnd(CDC* pDC)
{
return FALSE;
}
//*******************************************************************************************************/
示例13: UpdateTimeLight
void CTabpageLend::UpdateTimeLight(CString gunId)
{
vector<CBorrowRecord*> records;
CBorrowLogManager::GetInstance().GetRecordByGunId(gunId, records);
for (vector<CBorrowRecord*>::const_iterator iter = records.begin();
iter != records.end(); ++iter)
{
if ((*iter)->mEndTime == 0)
{
mCurrentRecord = *iter;
break;
}
}
__time64_t expectSeconds = 0;
CTime now = CTime::GetCurrentTime();
if (mCurrentRecord){
expectSeconds = mCurrentRecord->mExpectTime;
mCurrentRecord->mEndTime = now.GetTime();
}
CTime expectTime(expectSeconds);
mExpectDateCtrl.SetTime(&expectTime);
mExpectTimeCtrl.SetTime(&expectTime);
mEndDateCtrl.SetTime(&now);
mEndTimeCtrl.SetTime(&now);
if (expectTime.GetTime() > now.GetTime())
{
HBITMAP hTimeLight = (HBITMAP)mBmpPass.GetSafeHandle();
mTimeLight.SetBitmap(hTimeLight);
}else{
HBITMAP hTimeLight = (HBITMAP)mBmpFail.GetSafeHandle();
mTimeLight.SetBitmap(hTimeLight);
}
}
示例14: GetTimeStamp
/**
* get the modification date of the file
*
* @param fileName the file name
* @param timeStamp the timestamp
* @return TRUE if file exists,
* else FALSE
* @exception
* @see
*/
BOOL CEFile::GetTimeStamp(LPCTSTR fileName, time_t* pTimeStamp)
{
CFileFind finder;
BOOL bWorking = finder.FindFile(fileName);
if (bWorking)
{
CTime refTime;
bWorking = finder.FindNextFile();
finder.GetLastWriteTime( refTime ) ;
*pTimeStamp = refTime.GetTime();
return TRUE;
}
else
return FALSE;
}
示例15: GMTtoLocalTime
CTime GMTtoLocalTime( CTime CTgmt)
{
static boolean NotGotDiff = true;
static time_t diff = 0;
time_t gmt = CTgmt.GetTime();
if( NotGotDiff)
{
// Get GMT to Local time difference by looking at current time
time_t Now = time(NULL);
struct tm* TM = gmtime(&Now);
CTime gmtNow(TM->tm_year+1900,TM->tm_mon+1,TM->tm_mday,TM->tm_hour,TM->tm_min,TM->tm_sec);
diff = gmtNow.GetTime()-Now;
NotGotDiff = false;
}
return CTime(gmt-diff);
}