mirror of
https://github.com/jomjol/AI-on-the-edge-device.git
synced 2025-12-09 13:06:54 +03:00
Correct influx utc (#1964)
* Update interface_influxdb.cpp * Correct to UTC
This commit is contained in:
@@ -69,15 +69,20 @@ void InfluxDBPublish(std::string _key, std::string _content, std::string _timest
|
|||||||
strptime(_timestamp.c_str(), PREVALUE_TIME_FORMAT_OUTPUT, &tm);
|
strptime(_timestamp.c_str(), PREVALUE_TIME_FORMAT_OUTPUT, &tm);
|
||||||
time_t t = mktime(&tm); // t is now your desired time_t
|
time_t t = mktime(&tm); // t is now your desired time_t
|
||||||
|
|
||||||
|
struct tm * ptm;
|
||||||
|
ptm = gmtime ( &t );
|
||||||
|
time_t utc = mktime(ptm);
|
||||||
|
|
||||||
// time_t now;
|
// time_t now;
|
||||||
// time(&now);
|
// time(&now);
|
||||||
char nowTimestamp[21];
|
char nowTimestamp[21];
|
||||||
// pad with zeroes to get nanoseconds
|
// pad with zeroes to get nanoseconds
|
||||||
// sprintf(nowTimestamp,"%ld000000000", (long) now);
|
// sprintf(nowTimestamp,"%ld000000000", (long) now);
|
||||||
sprintf(nowTimestamp,"%ld000000000", (long) t);
|
// sprintf(nowTimestamp,"%ld000000000", (long) t); // Localtime
|
||||||
|
sprintf(nowTimestamp,"%ld000000000", (long) utc); // UTC
|
||||||
|
|
||||||
|
|
||||||
|
// LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "Test Time Conversion - t: " + std::to_string(t) + ", utc: " + std::to_string(utc));
|
||||||
// LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "Test Time Conversion - now: " + std::to_string(now) + ", timestamp: " + std::to_string(t) + "(correct time not used yet)");
|
// LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "Test Time Conversion - now: " + std::to_string(now) + ", timestamp: " + std::to_string(t) + "(correct time not used yet)");
|
||||||
|
|
||||||
std::string payload = _influxDBMeasurement + " " + _key + "=" + _content + " " + nowTimestamp;
|
std::string payload = _influxDBMeasurement + " " + _key + "=" + _content + " " + nowTimestamp;
|
||||||
|
|||||||
Reference in New Issue
Block a user