|
|
@@ -413,20 +413,11 @@ struct tm* parseTimestamp(const char *timestamp) {
|
|
|
}
|
|
|
|
|
|
void setSystemTime(struct tm *timeinfo) {
|
|
|
- time_t t = mktime(timeinfo);
|
|
|
- if (t == -1) {
|
|
|
- LOG_E("Failed to convert time to time_t");
|
|
|
- return;
|
|
|
- }
|
|
|
- // Convert the time_t value to a timeval structure
|
|
|
- struct timeval tv;
|
|
|
- tv.tv_sec = t;
|
|
|
- tv.tv_usec = 0; // Assuming no microseconds in the timestamp
|
|
|
- if (settimeofday(&tv, NULL) == -1) {
|
|
|
- LOG_E("Failed to set system time!");
|
|
|
- return;
|
|
|
+ if(set_date(timeinfo->tm_year+1900, timeinfo->tm_mon+1, timeinfo->tm_mday)==RT_EOK)
|
|
|
+ {
|
|
|
+ set_time(timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec);
|
|
|
+ LOG_I("System time set successfully:%04d-%02d-%02d-%02d-%02d-%02d!",timeinfo->tm_year+1900,timeinfo->tm_mon+1,timeinfo->tm_mday,timeinfo->tm_hour,timeinfo->tm_min,timeinfo->tm_sec);
|
|
|
}
|
|
|
- LOG_I("System time set successfully!");
|
|
|
}
|
|
|
|
|
|
// 函数定义:判断数组中是否有大于 100 的元素
|
|
|
@@ -1791,11 +1782,11 @@ int parseDtu(char *json_string)
|
|
|
{
|
|
|
timestamp_diff = tv.tv_sec - timestamp;
|
|
|
}
|
|
|
- if (tm_time != NULL&×tamp_diff>60) {
|
|
|
+ if (timestamp_diff>60) {
|
|
|
setSystemTime(tm_time);
|
|
|
- free(tm_time); // Free the allocated memory
|
|
|
}
|
|
|
}
|
|
|
+ free(tm_time); // Free the allocated memory
|
|
|
}
|
|
|
if(hum!=NULL&&tmp!=NULL)
|
|
|
{
|