comparison FXAnalyse.c @ 254:67c8ace9d5f6

Save time strings in UTC time and rotate datafiles at midnight UTC Time strings '05/06/2015 00:00:00.014' in datafiles were reported in Paris local time and the data files were rotated at midnight Paris time. Switch to use UTC time for both.
author Daniele Nicolodi <daniele@grinta.net>
date Fri, 05 Jun 2015 18:06:12 +0200
parents 10bf2bcdbbd4
children 708de02ef948
comparison
equal deleted inserted replaced
253:10bf2bcdbbd4 254:67c8ace9d5f6
1517 rollmean_zero(&rollmean_ch3); 1517 rollmean_zero(&rollmean_ch3);
1518 rollmean_zero(&rollmean_ch4); 1518 rollmean_zero(&rollmean_ch4);
1519 } 1519 }
1520 } 1520 }
1521 1521
1522 // local time 1522 struct tm *time = gmtime(&ev.time.tv_sec);
1523 struct tm *ltime = localtime(&ev.time.tv_sec);
1524 // round to milliseconds 1523 // round to milliseconds
1525 int msec = round(ev.time.tv_usec / 1000.0); 1524 int msec = round(ev.time.tv_usec / 1000.0);
1526 while (msec >= 1000) { 1525 while (msec >= 1000) {
1527 ltime->tm_sec += 1; 1526 time->tm_sec += 1;
1528 msec -= 1000; 1527 msec -= 1000;
1529 } 1528 }
1530 // format local time 1529 // format time
1531 char timestr[24]; 1530 char timestr[24];
1532 int len = strftime(timestr, sizeof(timestr), "%d/%m/%Y %H:%M:%S", ltime); 1531 int len = strftime(timestr, sizeof(timestr), "%d/%m/%Y %H:%M:%S", time);
1533 snprintf(timestr + len, sizeof(timestr) - len, ".%03d", msec); 1532 snprintf(timestr + len, sizeof(timestr) - len, ".%03d", msec);
1534 // display local time 1533 // display local time
1535 SetCtrlVal(MainPanel, PANEL_TIME, timestr); 1534 SetCtrlVal(MainPanel, PANEL_TIME, timestr);
1536 1535
1537 // run id derived from current local date in the form YYMMDD 1536 // run id derived from current date in the form YYMMDD
1538 char id[7]; 1537 char id[7];
1539 strftime(id, sizeof(id), "%y%m%d", ltime); 1538 strftime(id, sizeof(id), "%y%m%d", time);
1540 1539
1541 // write datafiles 1540 // write datafiles
1542 for (struct datafile *d = datafiles; d->data; d++) 1541 for (struct datafile *d = datafiles; d->data; d++)
1543 datafile_append(d, id, timestr); 1542 datafile_append(d, id, timestr);
1544 1543