Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CTime driving me mad. 1

Status
Not open for further replies.

mcowen

Programmer
Oct 21, 2001
134
GB
I have been trying to work out how to add 15 mins to a CTime object. It doesn't appear to be straightforward although there is an operator+ function.

Also, if I try to do the following code that comes from an example in the MSDN literature I get a very strange error...

CTime thetime = CTime::GetCurrentTime();

Gives me (just run from main)....

Compiling...
test.cpp
Linking...
nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __endthreadex
nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __beginthreadex
Debug/test.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.

test.exe - 3 error(s), 0 warning(s)
 
Try adding a CTimeSpan to the CTime
eg

CTime theTime;
theTime.GetCurrentTime();
//CTimeSpan constructor (days,hours,minutes,seconds)
CTimeSpan tsTemp(0,0,15,0);
theTime = theTime + tsTemp
 
There is something wrong with your project settings. Your current setting is "not using MFC DLL". But CTime is really a MFC function. You have to go to projects->settings->Microsoft Foundation classes to select "using MFC" (either a static libray or a shared DLL).
 
Sorry missed a bit

theTime.GetCurrentTime returns a CTime, it doesnt store the current time in theTime

should have been theTime = theTime.GetCurrentTime();
or theTime = CTime::GetCurrentTime();
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top