Hi moon,
As you mentioned "DoubleArray", I assume you are using "ChartDirector for C++".
In C++, because there is no data type for date/time, so in ChartDirector, we use our own format, which is the number of seconds elapsed since 0001-01-01 00:00:00. See:
https://www.advsofteng.com/doc/cdcpp.htm#dateformat.htm
ChartDirector includes two functions chartTime and chartTime2 to obtain the
"seconds elapsed since 0001-01-01 00:00:00". If your have the year, month, day of month, hour of day, minutes and seconds, you can use:
// for 2019-09-12 12:34:56
double stdate = Chart::chartTime(2019, 9, 12, 12, 34, 56);
In C++, sometimes people will use "Unix stamps", which is "seconds elapsed since 1-1-1970 00:00:00 GMT". This type of date/time is returned by the C function "time". If you have this type of date/time, you can convert it to ChartDirector date/time using Chart::chartTime2:
double endDate = Chart::chartTime2(date_time_in_unixstamp);
In charting, you would need an array of timestamps, an example is:
double timeStamps[100];
for (int i = 0; i < 100; ++i)
{
timeStamps[i] = ... get .. date/time at index i ...;
}
Of course, you can always dynamically allocate the array or using std::vector<double>, etc..
double *timeStamps = new double[100];
.....
In C, the array variable is treated like a pointer, and does not include the array size. (For example, if you have a variable of type "double *", it is not possible to know the array size.) But ChartDirector needs to know the array size to read the array. So in ChartDirector, we use the DoubleArray structure to combine the pointer and the array size:
// combine the timeStamps pointer with the size of 100
DoubleArray myTimeStamps = DoubleArray(timeStamps, 100);
Hope this can help.
Regards
Peter Kwan |