2010-10-16 69 views
0

我需要在C++中传递DateTime值。 (创建一个插件AmiBroker在C++中传递日期

我必须将它传递到AmiDate

我有长变量的日期。 (从1980年1月1日午夜起的秒数)

目标结构定义如下。

// 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 : 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 

    }; 

没有找到线索。

+0

什么是你的问题,它解码日期时间? – JoshD 2010-10-16 06:13:06

+0

你想做什么Manjoor?想要将AmiDate传递给一些函数?或者想将某些stdlib的时间转换为AmiDate? – SunnyShah 2010-10-16 06:19:34

+0

我怎么能通过日期? – Manjoor 2010-10-16 06:20:05

回答

1

一种选择是利用C时间库ctime为:

#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); 

现在,您可以提取struct tm对象,您刚刚填写的组成部分,并用它来填补你的AmiDate对象。

+0

也谷歌GetDateTimeArray() – Zabba 2010-10-16 06:36:14

0

我想你不能通过AmiDate将任何东西从AFL传递给DLL。只需像GetStockArray()(也在DLL中内部使用)函数来检索每个BarIndex的O,H,L,C和V,就可以在内部使用AmiDate结构。

除了每个BarIndex使用GetDateTimeArray()函数