ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  timestamp format?
Posted by moon on Dec-04-2019 18:08
I have known that the timestamp data format is DOUBLEARRY.
is it a pointer?
then I think that the actual value of timestamp is double.

what is the data format?

For example IF I have a data in text file
that has the time stamp data like "2019 09 12  23 30 21" for time stamp data,

how can II convert the text to double data?

doubla stdate=20190912233021; is correct?

thanks.

  Re: timestamp format?
Posted by Peter Kwan on Dec-05-2019 00:16
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

  Re: timestamp format?
Posted by moon on Dec-05-2019 08:11
Oh!!
I see.
Thanks a lot.