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

Message ListMessage List     Post MessagePost Message

  How to convert from double type time to Date format?
Posted by Cho on Dec-27-2017 09:02
Hello,

ChartDirector seems to use time to convert to double type like the code below.

SYSTEMTIME st;
GetLocalTime (& st);
double now = Chart :: chartTime (st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond) + st.wMilliseconds / 1000.0;

My question is two:
1) I want to know the code that reverses this double type to Date format.
2) Does ChartDirector have a function that converts double type time to Date format?


Regards,

Cho

  Re: How to convert from double type time to Date format?
Posted by Peter Kwan on Dec-27-2017 19:47
Hi Cho,

You may use the following method:

// Get the date as a number with 8 decimal digits reprensenting yyyymmdd
int yyyymmdd = Chart::getChartYMD(now);
int yyyy = yyyymmdd / 10000;
int mm = (yyyymmdd % 10000) / 10;
int dd = yyyymmdd % 100;

// To get the hh:nn:ss, you can use the following method (86400 is the number of seconds in 1 day)
int hh = (int)(fmod(now, 86400)) / 3600;
int nn = (int)(fmod(now, 3600)) / 60;
double ss = fmod(now, 60)

Hope this can help.

Regards
Peter Kwan