diff options
| author | Meco Man <[email protected]> | 2021-02-07 21:08:41 +0800 |
|---|---|---|
| committer | Meco Man <[email protected]> | 2021-02-07 21:08:41 +0800 |
| commit | f073911cd32bf8bfd02d6945db230e5e7b9b75ea (patch) | |
| tree | dcc48ceaf009960e89defb3ce712dc7feccec4a9 /bsp/bluetrum/libraries | |
| parent | 852d7d7552bd3fe898115ea16ba401970b0d1fad (diff) | |
解决底层驱动格林威治时间与当地时间胡乱使用的问题 mktime函数改为timegm函数
Diffstat (limited to 'bsp/bluetrum/libraries')
| -rw-r--r-- | bsp/bluetrum/libraries/hal_drivers/drv_rtc.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/bsp/bluetrum/libraries/hal_drivers/drv_rtc.c b/bsp/bluetrum/libraries/hal_drivers/drv_rtc.c index 9e84490158..99483cb544 100644 --- a/bsp/bluetrum/libraries/hal_drivers/drv_rtc.c +++ b/bsp/bluetrum/libraries/hal_drivers/drv_rtc.c @@ -10,6 +10,7 @@ #include "board.h" #include <time.h> +#include <sys/time.h> #ifdef BSP_USING_ONCHIP_RTC @@ -26,7 +27,7 @@ static struct rt_device rtc; uint8_t get_weekday(struct tm *const _tm) { uint8_t weekday; - time_t secs = mktime(_tm); + time_t secs = timegm(_tm); weekday = (secs / 86400 + 4) % 7; return weekday; @@ -115,7 +116,7 @@ void hal_rtc_init(void) tm_new.tm_mday = 29; tm_new.tm_mon = 1 - 1; tm_new.tm_year = 2021 - 1900; - sec = mktime(&tm_new); + sec = timegm(&tm_new); irtc_time_write(RTCCNT_CMD, sec); } |
