未验证 提交 20f5d934 编写于 作者: 还_没_想_好's avatar 还_没_想_好 提交者: GitHub

[libc][time] Fix bug (#5831)

上级 14d9709f
......@@ -371,22 +371,22 @@ time_t timegm(struct tm * const t)
register time_t i;
register time_t years = (time_t)t->tm_year - 70;
if (t->tm_sec > 60)
if (t->tm_sec > 60) /* seconds after the minute - [0, 60] including leap second */
{
t->tm_min += t->tm_sec / 60;
t->tm_sec %= 60;
}
if (t->tm_min > 60)
if (t->tm_min >= 60) /* minutes after the hour - [0, 59] */
{
t->tm_hour += t->tm_min / 60;
t->tm_min %= 60;
}
if (t->tm_hour > 24)
if (t->tm_hour >= 24) /* hours since midnight - [0, 23] */
{
t->tm_mday += t->tm_hour / 24;
t->tm_hour %= 24;
}
if (t->tm_mon > 12)
if (t->tm_mon >= 12) /* months since January - [0, 11] */
{
t->tm_year += t->tm_mon / 12;
t->tm_mon %= 12;
......@@ -503,7 +503,7 @@ RTM_EXPORT(nanosleep);
#ifdef RT_USING_POSIX_CLOCK
#ifdef RT_USING_RTC
static volatile struct timeval _timevalue;
static int _rt_clock_time_system_init()
static int _rt_clock_time_system_init(void)
{
register rt_base_t level;
time_t time = 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册