mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 00:14:22 +08:00
Replace mktime with timegm in rtc and fs driver
since kernel component should use UTC instead local time Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com> Change-Id: Icf939e1ab0af8e577105f539d2553bc67b3b3d10
This commit is contained in:
committed by
Alan Carvalho de Assis
parent
b1cd825cac
commit
ae9b5fd306
@@ -532,7 +532,7 @@ int up_rtc_gettime(FAR struct timespec *tp)
|
||||
|
||||
t.tm_year = rtc_bcd2dec((uint8_t) (bcd_years & 0xff)) + 100;
|
||||
|
||||
tp->tv_sec = mktime(&t);
|
||||
tp->tv_sec = timegm(&t);
|
||||
tp->tv_nsec = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -303,7 +303,7 @@ static int rx65n_settime(FAR struct rtc_lowerhalf_s *lower,
|
||||
* rtc_time is cast compatible with struct tm.
|
||||
*/
|
||||
|
||||
ts.tv_sec = mktime((FAR struct tm *)rtctime);
|
||||
ts.tv_sec = timegm((FAR struct tm *)rtctime);
|
||||
ts.tv_nsec = 0;
|
||||
|
||||
/* Now set the time (to one second accuracy) */
|
||||
@@ -446,7 +446,7 @@ static int rx65n_setrelative(FAR struct rtc_lowerhalf_s *lower,
|
||||
return ret;
|
||||
}
|
||||
|
||||
ts.tv_sec = mktime(&time);
|
||||
ts.tv_sec = timegm(&time);
|
||||
ts.tv_nsec = 0;
|
||||
|
||||
#elif defined(CONFIG_RTC_HIRES)
|
||||
@@ -457,7 +457,7 @@ static int rx65n_setrelative(FAR struct rtc_lowerhalf_s *lower,
|
||||
{
|
||||
/* Convert to seconds since the epoch */
|
||||
|
||||
seconds = mktime(&time);
|
||||
seconds = timegm(&time);
|
||||
|
||||
/* Add the seconds offset. Add one to the number of seconds
|
||||
* because we are unsure of the phase of the timer.
|
||||
|
||||
Reference in New Issue
Block a user