开发者

Passing date in c++

I need to pass DateTime value in C++. (Creating a plugin for AmiBroker)

I have to pass it to AmiDate .

I have date in long variable. (seconds from midnight January 1, 1980 )

The target structure is defined as below.

// 8 byte (64 bit) date time stamp
    union AmiDate
    {
     DATE_TIME_INT Date;
     struct PackedDate PackDate;
    };

struct PackedDate {
 // lower 32 bits
 unsigned int IsFuturePad:1; // bit marking "future data"
 unsigned int Reserved:5; // reserved set to zero
 unsigned int MicroSec:10; // microseconds 0..999
 unsigned int MilliSec:10; // milliseconds 0..999
 unsigned int Second: 6;  // 0..59

 // higher 32 bits
    unsigned int Minute开发者_JAVA技巧 : 6;    // 0..59      63 is reserved as EOD marker
    unsigned int Hour : 5;      // 0..23      31 is reserved as EOD marker
    unsigned int Day : 5;       // 1..31
    unsigned int Month : 4;     // 1..12
    unsigned int Year : 12;  // 0..4095

    };

Did not find a clue.


One option is to make use of the C time library ctime as:

#include <ctime>

time_t numSeconds = /* your value */;

// this structure contains the broken down components of the time.
struct tm * timeinfo;

// fill in the struct by calling localtime.
timeinfo = localtime ( &numSeconds);

Now you can extract the components from struct tm object that you just filled and use it to fill your AmiDate object.


I think you cannot pass anything from AFL to DLL using AmiDate.

The AmiDate Structure is used internally FOR DLLs only, Just function like the GetStockArray() (also used internally in DLL) to retrieve O,H,L,C,V of each BarIndex.

Except that it decode datetime of each BarIndex using the GetDateTimeArray() function

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜