Getting system time 
Author Message
 Getting system time

Hi,

I have made an test app which I want to expire after May 2000. This is what
I do:

CTime theTime;

BOOL MyApp::InitInstance()
{

int cMnt = theTime.GetMonth();
int cYear = theTime.GetYear();

if ((cMnt < 5) & (cYear=2000))
{
 run program

Quote:
}else

{
   MessageBox (NULL, "Sorry program has expired", "My App", MB_OK);

Quote:
}

 return False;

Quote:
}

The problem is that cMnt=1 and cYear=1970. Why?

Leif H



Fri, 16 Aug 2002 03:00:00 GMT  
 Getting system time
I quote from MSDN:

Each constructor is described below:

CTime( );   Constructs an _unitialized_ CTime object. This constructor
allows you to define CTime object arrays. You should initialize such
arrays with valid times prior to use.

End quote. Highlight is mine
--
With best wishes,
    Igor Tandetnik


Quote:
> Hi,

> I have made an test app which I want to expire after May 2000. This
is what
> I do:

> CTime theTime;

> BOOL MyApp::InitInstance()
> {

> int cMnt = theTime.GetMonth();
> int cYear = theTime.GetYear();

> if ((cMnt < 5) & (cYear=2000))

>  run program
> }else
> {
>    MessageBox (NULL, "Sorry program has expired", "My App", MB_OK);
> }

>  return False;
> }

> The problem is that cMnt=1 and cYear=1970. Why?

> Leif H



Fri, 16 Aug 2002 03:00:00 GMT  
 Getting system time
Leif,

The default CTime constructor gives you an unitialized object. Try:

CTime theTime = CTime::GetCurrentTime();

Quote:

> CTime theTime;

> BOOL MyApp::InitInstance()
> {

> int cMnt = theTime.GetMonth();
> int cYear = theTime.GetYear();
> The problem is that cMnt=1 and cYear=1970. Why?

Jim [VC/MFC MVP]
To send mail, change spam-me-not to msn


Fri, 16 Aug 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. getting system time on NT

2. runtime needed (getting system time?)

3. Getting system time from an NT server

4. HELP! Regards getting system time.

5. getting and useing system time

6. getting wrong system time

7. getting the system time format

8. Getting idle time of system/os

9. Getting system date/time at midnight?

10. Getting current system time in milliseconds

11. Minimum Wait Time (System Time Resolution)

12. Correct time counting when system time is changing

 

 
Powered by phpBB® Forum Software