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 : 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
ctimeas:Now you can extract the components from
struct tmobject that you just filled and use it to fill yourAmiDateobject.