localtim改为gmtime

This commit is contained in:
Meco Man 2021-02-07 21:49:25 +08:00
parent 64bd41d654
commit 86ebf17a23
20 changed files with 29 additions and 29 deletions

View File

@ -85,7 +85,7 @@ static rt_err_t rt_rtc_control(rt_device_t dev, int cmd, void *args)
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;

View File

@ -57,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;

View File

@ -104,7 +104,7 @@ static rt_err_t es32f0_rtc_control(rt_device_t dev, int cmd, void *args)
{
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. */

View File

@ -67,7 +67,7 @@ static rt_err_t es32f0_rtc_control(rt_device_t dev, int cmd, void *args)
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. */

View File

@ -67,7 +67,7 @@ static rt_err_t es32f0_rtc_control(rt_device_t dev, int cmd, void *args)
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. */

View File

@ -67,7 +67,7 @@ static rt_err_t es32f0_rtc_control(rt_device_t dev, int cmd, void *args)
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. */

View File

@ -45,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;

View File

@ -49,7 +49,7 @@ static int set_timestamp(time_t timestamp)
struct tm *p_tm;
snvs_hp_rtc_datetime_t rtcDate = {0};
p_tm = localtime(&timestamp);
p_tm = gmtime(&timestamp);
rtcDate.second = p_tm->tm_sec ;
rtcDate.minute = p_tm->tm_min ;

View File

@ -46,7 +46,7 @@ static int set_timestamp(time_t timestamp)
struct tm *p_tm;
rtc_datetime_t rtcDate;
p_tm = localtime(&timestamp);
p_tm = gmtime(&timestamp);
rtcDate.second = p_tm->tm_sec ;
rtcDate.minute = p_tm->tm_min ;

View File

@ -53,7 +53,7 @@ static int set_timestamp(time_t timestamp)
struct tm *p_tm;
RTC_TimeTypeDef rtcDate;
p_tm = localtime(&timestamp);
p_tm = gmtime(&timestamp);
rtcDate.Seconds= p_tm->tm_sec ;
rtcDate.Minutes= p_tm->tm_min ;

View File

@ -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;

View File

@ -232,7 +232,7 @@ static rt_err_t nu_rtc_control(rt_device_t dev, int cmd, void *args)
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;

View File

@ -233,7 +233,7 @@ static rt_err_t nu_rtc_control(rt_device_t dev, int cmd, void *args)
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);

View File

@ -194,7 +194,7 @@ static time_t raspi_get_timestamp(void)
static int raspi_set_timestamp(time_t timestamp)
{
struct tm *tblock;
tblock = localtime(&timestamp);
tblock = gmtime(&timestamp);
buf[0] = 0;
buf[1] = tblock->tm_sec;
buf[2] = tblock->tm_min;

View File

@ -41,7 +41,7 @@ static time_t raspi_get_timestamp(void)
static int raspi_set_timestamp(time_t timestamp)
{
struct tm *tblock;
tblock = localtime(&timestamp);
tblock = gmtime(&timestamp);
buf[0] = 0;
buf[1] = tblock->tm_sec;
buf[2] = tblock->tm_min;

View File

@ -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;

View File

@ -97,7 +97,7 @@ static rt_err_t swm320_rtc_control(rt_device_t dev, int cmd, void *args)
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. */

View File

@ -52,7 +52,7 @@ static int wm_set_timestamp(time_t timestamp)
struct tm *tblock;
tblock = localtime(&timestamp);
tblock = gmtime(&timestamp);
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(&timestamp);
tblock = gmtime(&timestamp);
tls_irq_enable(PMU_RTC_INT);

View File

@ -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. */

View File

@ -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)
{
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);
*((rt_time_t *)args) = timegm(&tm);
break;
case RT_DEVICE_CTRL_RTC_SET_TIME:
tm_ptr = localtime(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)