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