tags:

views:

11

answers:

1

Hello.

I currently have code that creates a CTime object from a defined value.

#define TIME_VALUE 0x301DDF00  // Aug 1, 1995 @ 04:00:00

CTime t = CTime( TIME_VALUE );

This creates the desired date of Aug 1, 1995 04:00:00

I can no longer use CTime so I am trying to use time_t and tm instead. Since the CTime constructor takes in the number of seconds since Jan 1, 1970 and time_t represents the number of seconds since Jan 1, 1970, I tried to use the following code.

#define TIME_VALUE 0x301DDF00  // Aug 1, 1995 @ 04:00:00

time_t tmpTime = TIME_VALUE;
struct tm createTime;

if( localtime_s( &createTime, &tmpTime ) == S_OK )
{ 
 // Use createTime
}

createTime ends up as August 1, 0095 04:00:00. How am I supposed to go from the defined value to a time_t and tm successfully?

Thanks in advance.

A: 

Sorry. I didn't look at the tm documentation closely enough. The year is the actual year minus 1900 and the month is zero based. I got it now.