|
Regarding Time value |
Posted by Sai on Nov-16-2012 21:29 |
|
I calculated time by following code
double dTime = m_timeStamps[0];
CTime tm;
tm = dTime;
CString sz;
sz = tm.Format("%d-%m-%Y %H:%M:%S");
dTime = *m_timeStamps.rbegin();
tm = dTime;
sz = sz + " - " + tm.Format("%H:%M:%S");
And time showing on X-Axis is very different.
So how do I know which one is correct?
Regards,
Sai |
Re: Regarding Time value |
Posted by Sai on Nov-16-2012 21:32 |
|
Just extension to previous post I am attaching screenshot of my application
|
Re: Regarding Time value |
Posted by Peter Kwan on Nov-17-2012 01:52 |
|
Hi Sai,
Unlikely other programming languages (such as C#, VB/VBScript/VB.NET, Java, etc), in C++, there is no such thing as date/time. So everyone is using a different method to represent date/time. In ChartDirector, the date/time should be represented as "clock seconds elapsed since Jan 01, 0001 00:00:00". In CTime, it uses a format that does not work before "Jan 01, 1970 00:00:00 GMT". This is certainly not usable for charting, as it is common to have data earlier than 1970.
So the key question is what type of data is in m_Timestamp? If it is time represented as "clock seconds elapsed since Jan 01, 0001 00:00:00" (which can be constructed using Chart::chartTime or Chart::chartTime2), or is it the CTime format (phyiscal seconds elasped since Jan 01, 1970 00:00:00 GMT). If the data are in ChartDirector time format, then the chart is correct. If your data are in CTime format, then CTime is correct. In this case, please convert the time to ChartDirector time format (eg. using Chart::chartTime2) before passing the data to ChartDirector.
Hope this can help.
Regards
Peter Kwan |
Re: Regarding Time value |
Posted by Sai on Nov-22-2012 20:27 |
|
Hi Peter,
As per suggestion I have converted time by chartTime & chartTime2.
1. dTime = Chart::chartTime(t.GetYear(), t.GetMonth(),t.GetDay(),t.GetHour(), t.GetMinute(), t.GetSecond());
m_timeStamps.push_back(dTime);
2. dTime = Chart::chartTime2((int)dTime);
m_timeStamps.push_back(dTime);
It doesn't work for me and one message box pops out.
---------------------------
ChartDirSample
---------------------------
The parameter is incorrect.
---------------------------
OK
--------------------------- |
Re: Regarding Time value |
Posted by Peter Kwan on Nov-23-2012 03:37 |
|
Hi Sai,
Would you mind to verify which line of code causes the pop up message? As far as I know, ChartDirector should be unable to cause this pop up message. For example, the following code may cause similar message if dTime is a chartTime (as opposed to MFC time), because CTime expects MFC time.
CTime tm;
tm = dTime;
Regards
Peter Kwan |
|