解决底层驱动格林威治时间与当地时间胡乱使用的问题 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
+2 -5
View File
@@ -13,10 +13,7 @@
#include <rtthread.h>
#include <rtdevice.h>
#ifndef _WIN32
#include <sys/time.h>
#endif
#define RT_RTC_YEARS_MAX 137
#ifdef RT_USING_SOFT_RTC
@@ -98,8 +95,8 @@ static void alarm_wakeup(struct rt_alarm *alarm, struct tm *now)
{
case RT_ALARM_ONESHOT:
{
sec_alarm = mktime(&alarm->wktime);
sec_now = mktime(now);
sec_alarm = timegm(&alarm->wktime);
sec_now = timegm(now);
if (((sec_now - sec_alarm) <= RT_ALARM_DELAY) && (sec_now >= sec_alarm))
{
/* stop alarm */
+2 -2
View File
@@ -8,7 +8,7 @@
* 2018-01-30 armink the first version
*/
#include <time.h>
#include <sys/time.h>
#include <string.h>
#include <rtthread.h>
#include <rtdevice.h>
@@ -126,7 +126,7 @@ int rt_soft_rtc_init(void)
#endif
init_tick = rt_tick_get();
init_time = mktime(&time_new);
init_time = timegm(&time_new);
soft_rtc_dev.type = RT_Device_Class_RTC;