diff --git a/bsp/apollo2/board/rtc.c b/bsp/apollo2/board/rtc.c index 1bc4779257..dbae7cf3c1 100644 --- a/bsp/apollo2/board/rtc.c +++ b/bsp/apollo2/board/rtc.c @@ -25,6 +25,7 @@ #include #include #include "am_mcu_apollo.h" +#include #define XT 1 #define LFRC 2 @@ -78,13 +79,13 @@ static rt_err_t rt_rtc_control(rt_device_t dev, int cmd, void *args) /* Seconds 0-59 : the 0-59 range */ time_temp.tm_sec = hal_time.ui32Second; - *time = mktime(&time_temp); + *time = timegm(&time_temp); break; case RT_DEVICE_CTRL_RTC_SET_TIME: time = (time_t *)args; - time_new = localtime(time); + time_new = gmtime(time); hal_time.ui32Hour = time_new->tm_hour; hal_time.ui32Minute = time_new->tm_min; diff --git a/bsp/at32/Libraries/rt_drivers/drv_rtc.c b/bsp/at32/Libraries/rt_drivers/drv_rtc.c index 48c634cdf2..bd4d89a9ed 100644 --- a/bsp/at32/Libraries/rt_drivers/drv_rtc.c +++ b/bsp/at32/Libraries/rt_drivers/drv_rtc.c @@ -10,6 +10,7 @@ #include "board.h" #include +#include #ifdef BSP_USING_RTC @@ -42,7 +43,7 @@ static time_t get_rtc_timestamp(void) tm_new.tm_year = ERTC_DateStruct.ERTC_Year + 100; LOG_D("get rtc time."); - return mktime(&tm_new); + return timegm(&tm_new); #else return RTC_GetCounter(); #endif @@ -56,7 +57,7 @@ static rt_err_t set_rtc_time_stamp(time_t time_stamp) struct tm *p_tm; - p_tm = localtime(&time_stamp); + p_tm = gmtime(&time_stamp); if (p_tm->tm_year < 100) { return -RT_ERROR; 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 +#include #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); } diff --git a/bsp/essemi/es32f0271/drivers/drv_rtc.c b/bsp/essemi/es32f0271/drivers/drv_rtc.c index 23bab4dc16..3e2cdd17a3 100644 --- a/bsp/essemi/es32f0271/drivers/drv_rtc.c +++ b/bsp/essemi/es32f0271/drivers/drv_rtc.c @@ -12,6 +12,7 @@ #include #include #include +#include #include "board.h" #include "drv_rtc.h" @@ -96,14 +97,14 @@ static rt_err_t es32f0_rtc_control(rt_device_t dev, int cmd, void *args) time_temp.tm_mday = date->day; time_temp.tm_mon = date->month - 1; time_temp.tm_year = date->year - 1900 + 2000; - *((time_t *)args) = mktime(&time_temp); + *((time_t *)args) = timegm(&time_temp); break; } case RT_DEVICE_CTRL_RTC_SET_TIME: { rt_enter_critical(); /* converts calendar time time into local time. */ - pNow = localtime((const time_t *)args); + pNow = gmtime((const time_t *)args); /* copy the statically located variable */ memcpy(&time_temp, pNow, sizeof(struct tm)); /* unlock scheduler. */ diff --git a/bsp/essemi/es32f0334/drivers/drv_rtc.c b/bsp/essemi/es32f0334/drivers/drv_rtc.c index 2ce6a408b1..9471368454 100644 --- a/bsp/essemi/es32f0334/drivers/drv_rtc.c +++ b/bsp/essemi/es32f0334/drivers/drv_rtc.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include "board.h" #include "drv_rtc.h" @@ -59,14 +60,14 @@ static rt_err_t es32f0_rtc_control(rt_device_t dev, int cmd, void *args) time_temp.tm_mday = date.day; time_temp.tm_mon = date.month - 1; time_temp.tm_year = date.year - 1900 + 2000; - *((time_t *)args) = mktime(&time_temp); + *((time_t *)args) = timegm(&time_temp); break; case RT_DEVICE_CTRL_RTC_SET_TIME: rt_enter_critical(); /* converts calendar time time into local time. */ - pNow = localtime((const time_t *)args); + pNow = gmtime((const time_t *)args); /* copy the statically located variable */ memcpy(&time_temp, pNow, sizeof(struct tm)); /* unlock scheduler. */ diff --git a/bsp/essemi/es32f0654/drivers/drv_rtc.c b/bsp/essemi/es32f0654/drivers/drv_rtc.c index 32a68c3011..cab5b8b61b 100644 --- a/bsp/essemi/es32f0654/drivers/drv_rtc.c +++ b/bsp/essemi/es32f0654/drivers/drv_rtc.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include "board.h" #include "drv_rtc.h" @@ -59,14 +60,14 @@ static rt_err_t es32f0_rtc_control(rt_device_t dev, int cmd, void *args) time_temp.tm_mday = date.day; time_temp.tm_mon = date.month - 1; time_temp.tm_year = date.year - 1900 + 2000; - *((time_t *)args) = mktime(&time_temp); + *((time_t *)args) = timegm(&time_temp); break; case RT_DEVICE_CTRL_RTC_SET_TIME: rt_enter_critical(); /* converts calendar time time into local time. */ - pNow = localtime((const time_t *)args); + pNow = gmtime((const time_t *)args); /* copy the statically located variable */ memcpy(&time_temp, pNow, sizeof(struct tm)); /* unlock scheduler. */ diff --git a/bsp/essemi/es32f369x/drivers/drv_rtc.c b/bsp/essemi/es32f369x/drivers/drv_rtc.c index 32a68c3011..cab5b8b61b 100644 --- a/bsp/essemi/es32f369x/drivers/drv_rtc.c +++ b/bsp/essemi/es32f369x/drivers/drv_rtc.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include "board.h" #include "drv_rtc.h" @@ -59,14 +60,14 @@ static rt_err_t es32f0_rtc_control(rt_device_t dev, int cmd, void *args) time_temp.tm_mday = date.day; time_temp.tm_mon = date.month - 1; time_temp.tm_year = date.year - 1900 + 2000; - *((time_t *)args) = mktime(&time_temp); + *((time_t *)args) = timegm(&time_temp); break; case RT_DEVICE_CTRL_RTC_SET_TIME: rt_enter_critical(); /* converts calendar time time into local time. */ - pNow = localtime((const time_t *)args); + pNow = gmtime((const time_t *)args); /* copy the statically located variable */ memcpy(&time_temp, pNow, sizeof(struct tm)); /* unlock scheduler. */ diff --git a/bsp/hc32f4a0/drivers/drv_rtc.c b/bsp/hc32f4a0/drivers/drv_rtc.c index 4ccaa46253..27e3a665df 100644 --- a/bsp/hc32f4a0/drivers/drv_rtc.c +++ b/bsp/hc32f4a0/drivers/drv_rtc.c @@ -8,8 +8,11 @@ * 2020-10-30 CDT first version */ -#include "board.h" +#include #include +#include +#include +#include #ifdef BSP_USING_RTC @@ -33,7 +36,7 @@ static time_t hc32_rtc_get_time_stamp(void) tm_new.tm_wday = stcRtcDate.u8Weekday; LOG_D("get rtc time."); - return mktime(&tm_new); + return timegm(&tm_new); } static rt_err_t hc32_rtc_set_time_stamp(time_t time_stamp) @@ -42,7 +45,7 @@ static rt_err_t hc32_rtc_set_time_stamp(time_t time_stamp) stc_rtc_date_t stcRtcDate = {0}; struct tm *p_tm; - p_tm = localtime(&time_stamp); + p_tm = gmtime(&time_stamp); if (p_tm->tm_year < 100) { return -RT_ERROR; diff --git a/bsp/imxrt/libraries/drivers/drv_rtc.c b/bsp/imxrt/libraries/drivers/drv_rtc.c index 84e9e51074..96ae1006fa 100644 --- a/bsp/imxrt/libraries/drivers/drv_rtc.c +++ b/bsp/imxrt/libraries/drivers/drv_rtc.c @@ -10,6 +10,8 @@ * */ #include +#include +#include #ifdef BSP_USING_RTC @@ -39,7 +41,7 @@ static time_t get_timestamp(void) tm_new.tm_mon = rtcDate.month - 1; tm_new.tm_year = rtcDate.year - 1900; - return mktime(&tm_new); + return timegm(&tm_new); } static int set_timestamp(time_t timestamp) @@ -47,7 +49,7 @@ static int set_timestamp(time_t timestamp) struct tm *p_tm; snvs_hp_rtc_datetime_t rtcDate = {0}; - p_tm = localtime(×tamp); + p_tm = gmtime(×tamp); rtcDate.second = p_tm->tm_sec ; rtcDate.minute = p_tm->tm_min ; diff --git a/bsp/lpc55sxx/Libraries/drivers/drv_rtc.c b/bsp/lpc55sxx/Libraries/drivers/drv_rtc.c index 5e160bc471..c277d82079 100644 --- a/bsp/lpc55sxx/Libraries/drivers/drv_rtc.c +++ b/bsp/lpc55sxx/Libraries/drivers/drv_rtc.c @@ -8,12 +8,13 @@ * 2018-03-15 Liuguang the first version. * 2019-07-19 Magicoe The first version for LPC55S6x */ - + +#include +#include +#include #include "drv_rtc.h" - #include "fsl_common.h" #include "fsl_rtc.h" -#include #ifdef RT_USING_RTC @@ -37,7 +38,7 @@ static time_t get_timestamp(void) tm_new.tm_mon = rtcDate.month - 1; tm_new.tm_year = rtcDate.year - 1900; - return mktime(&tm_new); + return timegm(&tm_new); } static int set_timestamp(time_t timestamp) @@ -45,7 +46,7 @@ static int set_timestamp(time_t timestamp) struct tm *p_tm; rtc_datetime_t rtcDate; - p_tm = localtime(×tamp); + p_tm = gmtime(×tamp); rtcDate.second = p_tm->tm_sec ; rtcDate.minute = p_tm->tm_min ; diff --git a/bsp/ls1cdev/drivers/drv_rtc.c b/bsp/ls1cdev/drivers/drv_rtc.c index 0569992c61..ef1398fe47 100644 --- a/bsp/ls1cdev/drivers/drv_rtc.c +++ b/bsp/ls1cdev/drivers/drv_rtc.c @@ -12,6 +12,7 @@ #include "board.h" #include "drv_rtc.h" #include +#include #include "../libraries/ls1c_regs.h" #include "../libraries/ls1c_rtc.h" @@ -44,7 +45,7 @@ static time_t get_timestamp(void) tm_new.tm_mon = rtcDate.Month- 1; tm_new.tm_year = rtcDate.Year + 2000 - 1900; - return mktime(&tm_new); + return timegm(&tm_new); } static int set_timestamp(time_t timestamp) @@ -52,7 +53,7 @@ static int set_timestamp(time_t timestamp) struct tm *p_tm; RTC_TimeTypeDef rtcDate; - p_tm = localtime(×tamp); + p_tm = gmtime(×tamp); rtcDate.Seconds= p_tm->tm_sec ; rtcDate.Minutes= p_tm->tm_min ; diff --git a/bsp/ls2kdev/drivers/drv_rtc.c b/bsp/ls2kdev/drivers/drv_rtc.c index ef8dfcda82..3cea0288be 100644 --- a/bsp/ls2kdev/drivers/drv_rtc.c +++ b/bsp/ls2kdev/drivers/drv_rtc.c @@ -14,7 +14,7 @@ #include #include #include -#include +#include #include "ls2k1000.h" #ifdef RT_USING_RTC @@ -128,7 +128,7 @@ static rt_err_t rt_rtc_ioctl(rt_device_t dev, int cmd, void *args) hw_rtc = dev->user_data; t = (time_t *)args; - time = *localtime(t); + time = *gmtime(t); rtctm.sys_toyread0 = hw_rtc->sys_toyread0; rtctm.sys_toyread1 = hw_rtc->sys_toyread1; @@ -137,29 +137,29 @@ static rt_err_t rt_rtc_ioctl(rt_device_t dev, int cmd, void *args) switch (cmd) { - case RT_DEVICE_CTRL_RTC_GET_TIME: - *t = mktime(&tmptime); - break; - case RT_DEVICE_CTRL_RTC_SET_TIME: - tmptime.tm_hour = time.tm_hour; - tmptime.tm_min = time.tm_min; - tmptime.tm_sec = time.tm_sec; + case RT_DEVICE_CTRL_RTC_GET_TIME: + *t = timegm(&tmptime); + break; + case RT_DEVICE_CTRL_RTC_SET_TIME: + tmptime.tm_hour = time.tm_hour; + tmptime.tm_min = time.tm_min; + tmptime.tm_sec = time.tm_sec; - tmptime.tm_year = time.tm_year; - tmptime.tm_mon = time.tm_mon; - tmptime.tm_mday = time.tm_mday; + tmptime.tm_year = time.tm_year; + tmptime.tm_mon = time.tm_mon; + tmptime.tm_mday = time.tm_mday; - rtctm = mkrtctime(&tmptime); - /* write to hw RTC */ - hw_rtc->sys_toywrite0 = rtctm.sys_toyread0; - hw_rtc->sys_toywrite1 = rtctm.sys_toyread1; - break; - case RT_DEVICE_CTRL_RTC_GET_ALARM: - break; - case RT_DEVICE_CTRL_RTC_SET_ALARM: - break; - default: - break; + rtctm = mkrtctime(&tmptime); + /* write to hw RTC */ + hw_rtc->sys_toywrite0 = rtctm.sys_toyread0; + hw_rtc->sys_toywrite1 = rtctm.sys_toyread1; + break; + case RT_DEVICE_CTRL_RTC_GET_ALARM: + break; + case RT_DEVICE_CTRL_RTC_SET_ALARM: + break; + default: + break; } return RT_EOK; diff --git a/bsp/nrf5x/libraries/drivers/drv_rtc.c b/bsp/nrf5x/libraries/drivers/drv_rtc.c index e7a7359523..ab65192395 100644 --- a/bsp/nrf5x/libraries/drivers/drv_rtc.c +++ b/bsp/nrf5x/libraries/drivers/drv_rtc.c @@ -11,7 +11,7 @@ #include "board.h" #include #include - +#include #include #include @@ -118,7 +118,7 @@ static rt_err_t rt_hw_rtc_register(rt_device_t device, const char *name, rt_uint RT_ASSERT(device != RT_NULL); - init_time = mktime(&time_new); + init_time = timegm(&time_new); if (rt_rtc_config(device) != RT_EOK) { return -RT_ERROR; diff --git a/bsp/nuvoton/libraries/m480/rtt_port/drv_rtc.c b/bsp/nuvoton/libraries/m480/rtt_port/drv_rtc.c index 804c0a0a0c..a80ac79627 100644 --- a/bsp/nuvoton/libraries/m480/rtt_port/drv_rtc.c +++ b/bsp/nuvoton/libraries/m480/rtt_port/drv_rtc.c @@ -14,6 +14,7 @@ #if defined (BSP_USING_RTC) #include +#include #include /* Private define ---------------------------------------------------------------*/ @@ -183,8 +184,8 @@ static rt_err_t nu_rtc_is_date_valid(const time_t *const t) if (!initialised) { - t_upper = mktime((struct tm *)&tm_upper); - t_lower = mktime((struct tm *)&tm_lower); + t_upper = timegm((struct tm *)&tm_upper); + t_lower = timegm((struct tm *)&tm_lower); initialised = RT_TRUE; } @@ -225,13 +226,13 @@ static rt_err_t nu_rtc_control(rt_device_t dev, int cmd, void *args) tm_out.tm_hour = hw_time.u32Hour; tm_out.tm_min = hw_time.u32Minute; tm_out.tm_sec = hw_time.u32Second; - *time = mktime(&tm_out); + *time = timegm(&tm_out); break; case RT_DEVICE_CTRL_RTC_SET_TIME: time = (time_t *) args; - tm_in = localtime(time); + tm_in = gmtime(time); if (nu_rtc_is_date_valid(time) != RT_EOK) return RT_ERROR; diff --git a/bsp/nuvoton/libraries/nuc980/rtt_port/drv_rtc.c b/bsp/nuvoton/libraries/nuc980/rtt_port/drv_rtc.c index 98b3f1b228..49418316d1 100644 --- a/bsp/nuvoton/libraries/nuc980/rtt_port/drv_rtc.c +++ b/bsp/nuvoton/libraries/nuc980/rtt_port/drv_rtc.c @@ -14,6 +14,7 @@ #if defined (BSP_USING_RTC) #include +#include #include #include @@ -184,8 +185,8 @@ static rt_err_t nu_rtc_is_date_valid(const time_t *const t) if (!initialised) { - t_upper = mktime((struct tm *)&tm_upper); - t_lower = mktime((struct tm *)&tm_lower); + t_upper = timegm((struct tm *)&tm_upper); + t_lower = timegm((struct tm *)&tm_lower); initialised = RT_TRUE; } @@ -226,13 +227,13 @@ static rt_err_t nu_rtc_control(rt_device_t dev, int cmd, void *args) tm_out.tm_hour = hw_time.u32Hour; tm_out.tm_min = hw_time.u32Minute; tm_out.tm_sec = hw_time.u32Second; - *time = mktime(&tm_out); + *time = timegm(&tm_out); break; case RT_DEVICE_CTRL_RTC_SET_TIME: time = (time_t *) args; - tm_in = localtime(time); + tm_in = gmtime(time); if (nu_rtc_is_date_valid(time) != RT_EOK) return -(RT_ERROR); diff --git a/bsp/raspberry-pi/raspi3-32/driver/drv_rtc.c b/bsp/raspberry-pi/raspi3-32/driver/drv_rtc.c index 8a33e2be64..147504bd16 100644 --- a/bsp/raspberry-pi/raspi3-32/driver/drv_rtc.c +++ b/bsp/raspberry-pi/raspi3-32/driver/drv_rtc.c @@ -8,12 +8,15 @@ * 2019-07-29 zdzn first version */ +#include +#include +#include #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,13 +188,13 @@ 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) { struct tm *tblock; - tblock = localtime(×tamp); + tblock = gmtime(×tamp); buf[0] = 0; buf[1] = tblock->tm_sec; buf[2] = tblock->tm_min; diff --git a/bsp/raspberry-pi/raspi3-64/driver/drv_rtc.c b/bsp/raspberry-pi/raspi3-64/driver/drv_rtc.c index e38393bbd0..18fd6474a2 100644 --- a/bsp/raspberry-pi/raspi3-64/driver/drv_rtc.c +++ b/bsp/raspberry-pi/raspi3-64/driver/drv_rtc.c @@ -8,7 +8,9 @@ * 2019-07-29 zdzn first version */ - +#include +#include +#include #include "drv_rtc.h" #ifdef BSP_USING_RTC @@ -33,13 +35,13 @@ 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) { struct tm *tblock; - tblock = localtime(×tamp); + tblock = gmtime(×tamp); buf[0] = 0; buf[1] = tblock->tm_sec; buf[2] = tblock->tm_min; diff --git a/bsp/stm32f20x/Drivers/drv_rtc.c b/bsp/stm32f20x/Drivers/drv_rtc.c index 3c70a417d2..6078a15249 100644 --- a/bsp/stm32f20x/Drivers/drv_rtc.c +++ b/bsp/stm32f20x/Drivers/drv_rtc.c @@ -115,7 +115,7 @@ static rt_err_t rt_rtc_control(rt_device_t dev, int cmd, void *args) /* Change the current time */ //RTC_SetCounter(*time); - to = localtime(time); + to = gmtime(time); RTC_TimeStructure.RTC_Seconds = to->tm_sec; RTC_TimeStructure.RTC_Minutes = to->tm_min; RTC_TimeStructure.RTC_Hours = to->tm_hour; diff --git a/bsp/swm320-lq100/drivers/drv_rtc.c b/bsp/swm320-lq100/drivers/drv_rtc.c index 51597ba73d..5219a5b013 100644 --- a/bsp/swm320-lq100/drivers/drv_rtc.c +++ b/bsp/swm320-lq100/drivers/drv_rtc.c @@ -13,7 +13,7 @@ #include #include #include -#include +#include /** * This function will get the weed day from a date. @@ -92,12 +92,12 @@ static rt_err_t swm320_rtc_control(rt_device_t dev, int cmd, void *args) time_temp.tm_mday = dateTime.Date; time_temp.tm_mon = dateTime.Month - 1; time_temp.tm_year = dateTime.Year - 1900; - *((time_t *)args) = mktime(&time_temp); + *((time_t *)args) = timegm(&time_temp); break; case RT_DEVICE_CTRL_RTC_SET_TIME: rt_enter_critical(); /* converts calendar time time into local time. */ - pNow = localtime((const time_t *)args); + pNow = gmtime((const time_t *)args); /* copy the statically located variable */ memcpy(&time_temp, pNow, sizeof(struct tm)); /* unlock scheduler. */ diff --git a/bsp/w60x/drivers/drv_rtc.c b/bsp/w60x/drivers/drv_rtc.c index fbf6060691..fa0aee498c 100644 --- a/bsp/w60x/drivers/drv_rtc.c +++ b/bsp/w60x/drivers/drv_rtc.c @@ -11,7 +11,7 @@ #include #include -#include +#include #include "wm_regs.h" #include "wm_irq.h" #include "tls_common.h" @@ -42,7 +42,7 @@ static time_t wm_get_timestamp(void) tm_new.tm_min = (ctrl1 & 0x00003f00) >> 8; tm_new.tm_sec = ctrl1 & 0x0000003f; - return mktime(&tm_new); + return timegm(&tm_new); } static int wm_set_timestamp(time_t timestamp) @@ -52,7 +52,7 @@ static int wm_set_timestamp(time_t timestamp) struct tm *tblock; - tblock = localtime(×tamp); + tblock = gmtime(×tamp); ctrl2 = tls_reg_read32(HR_PMU_RTC_CTRL2); /* disable */ ctrl2 &= ~(1 << 16); @@ -84,7 +84,7 @@ static int wm_alarm_set_timestamp(struct rt_rtc_wkalarm *wkalarm) time_t timestamp = 0; timestamp = wm_get_timestamp(); - tblock = localtime(×tamp); + tblock = gmtime(×tamp); tls_irq_enable(PMU_RTC_INT); diff --git a/components/dfs/filesystems/elmfat/dfs_elm.c b/components/dfs/filesystems/elmfat/dfs_elm.c index 82d04ae0cc..d8c38e96ae 100644 --- a/components/dfs/filesystems/elmfat/dfs_elm.c +++ b/components/dfs/filesystems/elmfat/dfs_elm.c @@ -21,7 +21,7 @@ #include "ffconf.h" #include "ff.h" #include -#include +#include /* ELM FatFs provide a DIR struct */ #define HAVE_DIR_STRUCTURE @@ -800,7 +800,7 @@ int dfs_elm_stat(struct dfs_filesystem *fs, const char *path, struct stat *st) tm_file.tm_min = min; /* Minutes: 0-59 */ tm_file.tm_sec = sec; /* Seconds: 0-59 */ - st->st_mtime = mktime(&tm_file); + st->st_mtime = timegm(&tm_file); } /* get st_mtime. */ } @@ -956,7 +956,7 @@ DWORD get_fattime(void) /* lock scheduler. */ rt_enter_critical(); /* converts calendar time time into local time. */ - p_tm = localtime(&now); + p_tm = gmtime(&now); /* copy the statically located variable */ memcpy(&tm_now, p_tm, sizeof(struct tm)); /* unlock scheduler. */ diff --git a/components/drivers/rtc/alarm.c b/components/drivers/rtc/alarm.c index ea1b150e7a..d8e4e468a7 100644 --- a/components/drivers/rtc/alarm.c +++ b/components/drivers/rtc/alarm.c @@ -13,10 +13,7 @@ #include #include - -#ifndef _WIN32 #include -#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 */ diff --git a/components/drivers/rtc/soft_rtc.c b/components/drivers/rtc/soft_rtc.c index 6a04314675..240301f683 100644 --- a/components/drivers/rtc/soft_rtc.c +++ b/components/drivers/rtc/soft_rtc.c @@ -8,7 +8,7 @@ * 2018-01-30 armink the first version */ -#include +#include #include #include #include @@ -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; diff --git a/libcpu/arm/s3c24x0/rtc.c b/libcpu/arm/s3c24x0/rtc.c index d0c80bce6b..73de840b37 100644 --- a/libcpu/arm/s3c24x0/rtc.c +++ b/libcpu/arm/s3c24x0/rtc.c @@ -12,7 +12,7 @@ */ #include -#include +#include #include // #define RTC_DEBUG @@ -125,27 +125,27 @@ static rt_size_t rtc_read(rt_device_t dev, rt_off_t pos, void* buffer, rt_size_t static rt_err_t rtc_control(rt_device_t dev, int cmd, void *args) { - struct tm tm, *tm_ptr; + struct tm tm, *tm_ptr; time_t *time; - RT_ASSERT(dev != RT_NULL); + RT_ASSERT(dev != RT_NULL); - time = (time_t *)args; - switch (cmd) - { - case RT_DEVICE_CTRL_RTC_GET_TIME: - /* read device */ - rt_hw_rtc_get(&tm); - *((rt_time_t *)args) = mktime(&tm); - break; + time = (time_t *)args; + switch (cmd) + { + case RT_DEVICE_CTRL_RTC_GET_TIME: + /* read device */ + rt_hw_rtc_get(&tm); + *((rt_time_t *)args) = timegm(&tm); + break; - case RT_DEVICE_CTRL_RTC_SET_TIME: - tm_ptr = localtime(time); - /* write device */ - rt_hw_rtc_set(tm_ptr); - break; - } + case RT_DEVICE_CTRL_RTC_SET_TIME: + /* write device */ + tm_ptr = gmtime(time); + rt_hw_rtc_set(tm_ptr); + break; + } - return RT_EOK; + return RT_EOK; } void rt_hw_rtc_init(void)