解决底层驱动格林威治时间与当地时间胡乱使用的问题 mktime函数改为timegm函数

This commit is contained in:
Meco Man
2021-02-07 21:08:41 +08:00
parent 852d7d7552
commit f073911cd3
22 changed files with 81 additions and 63 deletions

View File

@@ -8,12 +8,15 @@
* 2019-07-29 zdzn first version
*/
#include <rtthread.h>
#include <rtdevice.h>
#include <sys/time.h>
#include "drv_rtc.h"
#ifdef BSP_USING_RTC
#define RTC_I2C_BUS_NAME "i2c0"
#define RTC_ADDR 0x68
#define RTC_ADDR 0x68
static struct rt_device rtc_device;
static struct rt_i2c_bus_device *i2c_bus = RT_NULL;
@@ -185,7 +188,7 @@ static time_t raspi_get_timestamp(void)
tm_new.tm_min = ((buf[1] & 0x7F) / 16 + 0x30) + (buf[1] & 0x7F) % 16+ 0x30;
tm_new.tm_sec = ((buf[0] & 0x7F) / 16 + 0x30) + (buf[0] & 0x7F) % 16+ 0x30;
return mktime(&tm_new);
return timegm(&tm_new);
}
static int raspi_set_timestamp(time_t timestamp)

View File

@@ -8,7 +8,9 @@
* 2019-07-29 zdzn first version
*/
#include <rtthread.h>
#include <rtdevice.h>
#include <sys/time.h>
#include "drv_rtc.h"
#ifdef BSP_USING_RTC
@@ -33,7 +35,7 @@ static time_t raspi_get_timestamp(void)
tm_new.tm_min = ((buf[1] & 0x7F) / 16 + 0x30) + (buf[1] & 0x7F) % 16+ 0x30;
tm_new.tm_sec = ((buf[0] & 0x7F) / 16 + 0x30) + (buf[0] & 0x7F) % 16+ 0x30;
return mktime(&tm_new);
return timegm(&tm_new);
}
static int raspi_set_timestamp(time_t timestamp)