mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2025-12-25 16:57:20 +00:00
解决底层驱动格林威治时间与当地时间胡乱使用的问题 mktime函数改为timegm函数
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user