My computer:
Visual Studio 2008, qt 4.7, qwt 6.0

Hi,

I am making a qwt plot from a very large file that has time and prices. The times in the file are all in Unix time as doubles. The plot comes out great with time on the x-axis and prices on the y-axis. The only problem is that the times are all in Unix and not very useful to look at. Does anyone know if there is a way that I can convert the times on the plot into human-readable dates? The kinds of files that I want to plot come from online databases and are all in Unix time.

The only thing I can think of is loading up all the time data from the files and using mktime to make them all into readable dates, but I don't really know how I'd do that. It seems like a lot of work (especially because the files have between 2-4 million time values) Also, I'm not sure if changing these files would make my code break (like the numOfPts when I load the data)...

here is some of my code:


Qt Code:
  1. newPlot::newPlot()
  2. {
  3. QwtScaleEngine::Floating;
  4. QwtPlotCurve *Curve = new QwtPlotCurve("plotty");
  5. Curve->setPen(QPen(Qt::red));
  6. Curve->setStyle(QwtPlotCurve::Steps);
  7. Curve->attach(this);
  8.  
  9. ////chose which file to load and load the data
  10. char * FileName = "C:/data/....price_and_time";
  11. FILE * fp = fopen ( FileName, "rb");
  12. if(fp == NULL) EXCEPTION( "no file" );
  13.  
  14. fseek(fp, 0, SEEK_END);
  15. int numOfPts = ftell( fp )/ (2 * sizeof (double));
  16.  
  17. double *time = new double[numOfPts];
  18. double *value = new double[numOfPts];
  19. double *tempTime = time;
  20. double *tempValue = value;
  21.  
  22. fseek(fp, 0, 0);
  23. for( int i=0; i<numOfPts; i++){
  24. int j = fread(tempTime, sizeof(double), 1, fp);
  25. int k = fread(tempValue, sizeof(double), 1, fp);
  26. tempTime++;
  27. tempValue++;
  28. }
  29. Curve->setRawSamples(time, value, numOfPts);
  30. }
  31.  
  32. if (fp!=NULL)
  33. fclose(fp);
  34. }
To copy to clipboard, switch view to plain text mode 

I am putting the plot into a gui so that I can add features later:

Qt Code:
  1. class MyWidget : public QWidget{
  2. public:
  3. MyWidget(QWidget *parent = 0);
  4. };
  5.  
  6. MyWidget::MyWidget(QWidget *parent):QWidget(parent)
  7. {
  8. setFixedSize(1500,750);
  9. newPlot *myPlot = new newPlot;
  10. QVBoxLayout *layout = new QVBoxLayout;
  11.  
  12. layout->addWidget(myPlot);
  13. setLayout(layout);
  14. }
  15.  
  16.  
  17. int main(int argc, char * argv[])
  18. {
  19. QApplication app(argc, argv);
  20. MyWidget widget;
  21. widget.show();
  22. return app.exec();
  23.  
  24. }
To copy to clipboard, switch view to plain text mode 



Any ideas?

Thanks for your help!