|
timestamp / 1970 |
Posted by Mrx Rch on Jun-30-2017 02:47 |
|
Hello,
the chart shows me year 0046 instead of 2015 - do you know why?
(when I check the timestamp is correct)
DoubleArray timeStamps = DoubleArray(candlesData.timeStamps.data + startIndex, noOfPoints);
=> the timeStamps are correct
QDateTime qd;
qd = QDateTime::fromTime_t(timeStamps[0]);
QString ssst = qd.toString("yyyy-MM-ddThh:mm:ss.000000000Z");
=> it shows 2015. ("2015-01-01T22:05:00.000000000Z")
However on the chart appears 0046 (like the legend).
thx, Rch |
Re: timestamp / 1970 |
Posted by Peter Kwan on Jun-30-2017 21:11 |
|
Hi Mrx,
May be your timeStamps are UNIX timestamps (elapsed seconds since 1970-01-01 00:00:00 GMT). ChartDirector uses a different timestamps defined as the clock seconds since 0001-01-01 00:00:00. It is because the UNIX timestamps are too limited and not suitable to represent historical time.
If you are in fact using UNIX timestamps, ChartDirector has a function Chart::chartTime2 to convert it to ChartDirector timestamps:
for (int i = 0; i < candlesData.timeStamps.len; ++i)
candlesData.timeStamps.data[i] = Chart::chartTime2(candlesData.timeStamps.data[i]);
Hope this can help.
Regards
Peter Kwan |
Re: timestamp / 1970 |
Posted by Mrx Rch on Jul-01-2017 03:28 |
|
Hello Peter,
you are really great!
solved my problem.
I initially converted it from a string, using
// date looks like: "2015-01-01T0:00:00.000000000Z"
timeStamps[i] = QDateTime::fromString(fullCandles[i].time.c_str(), "yyyy-MM-ddThh:mm:ss.000000000Z").toTime_t();
so, I added:
timeStamps[i] = Chart::chartTime2(timeStamps[i]);
and now it works... (maybe there is a simple conversion from string into chartTime2 ?)
thx, Rch |
Re: timestamp / 1970 |
Posted by Peter Kwan on Jul-02-2017 18:30 |
|
Hi Mrx Rch,
I think you just need to combine the QDateTime and chatrTime2 method, like:
timeStamps[i] = Chart::chartTime2(QDateTime::fromString(fullCandles[i].time.c_str(), "yyyy-MM-ddThh:mm:ss.000000000Z").toTime_t());
Hope this can help.
Regards
Peter Kwan |
Re: timestamp / 1970 |
Posted by Mrx Rch on Jul-03-2017 03:21 |
|
yep - many thx!
Rch |
|