You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if(t == RT_NULL)
{
rt_set_errno(EFAULT);
return (time_t)-1;
}
years = (time_t)t->tm_year - 70;
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) /* minutes after the hour - [0, 59] */
{
t->tm_hour += t->tm_min / 60;
t->tm_min %= 60;
}
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) /* months since January - [0, 11] */
{
t->tm_year += t->tm_mon / 12;
t->tm_mon %= 12;
}
while (t->tm_mday > (__spm[t->tm_mon + 1] - __spm[t->tm_mon]))
{
int days_in_month = __spm[t->tm_mon + 1] - __spm[t->tm_mon];
if (t->tm_mon == 1 && __isleap(t->tm_year + 1900))
days_in_month = 29;
t->tm_mday -= days_in_month;
if (++t->tm_mon >= 12) {
t->tm_mon = 0;
++t->tm_year;
}
}
while (t->tm_mday <= 0) {
if (--t->tm_mon < 0) {
t->tm_mon = 11;
--t->tm_year;
}
int days_in_month = __spm[t->tm_mon + 1] - __spm[t->tm_mon];
if (t->tm_mon == 1 && __isleap(t->tm_year + 1900))
days_in_month = 29;
t->tm_mday += days_in_month;
}
years = (time_t)t->tm_year - 70;
if (t->tm_year < 70)
{
rt_set_errno(EINVAL);
return (time_t) -1;
}
/* Days since 1970 is 365 * number of years + number of leap years since 1970 */
day = years * 365 + (years + 1) / 4;
/* After 2100 we have to substract 3 leap years for every 400 years
This is not intuitive. Most mktime implementations do not support
dates after 2059, anyway, so we might leave this out for it's
bloat. */
if (years >= 131)
{
years -= 131;
years /= 100;
day -= (years >> 2) * 3 + 1;
if ((years &= 3) == 3)
years--;
day -= years;
}
day += t->tm_yday = __spm[t->tm_mon] + t->tm_mday - 1 +
(__isleap(t->tm_year + 1900) & (t->tm_mon > 1));
/* day is now the number of days since 'Jan 1 1970' */
i = 7;
t->tm_wday = (int)((day + 4) % i); /* Sunday=0, Monday=1, ..., Saturday=6 */
i = 24;
day *= i;
i = 60;
return ((day + t->tm_hour) * i + t->tm_min) * i + t->tm_sec;
Activity
github-actions commentedon Aug 5, 2026
如需认领并处理此 Issue,请评论
/claim。To claim and work on this issue, comment
/claim.[-][Bug][/-][+][Bug] 内核mktime函数bug[/+]Memory-afk commentedon Aug 5, 2026
这是我的临时解决方案
time_t timegm(struct tm * const t)
{
time_t day;
time_t i;
time_t years;
}
RTM_EXPORT(timegm);
github-actions commentedon Aug 5, 2026
@Memory-afk has claimed this issue. GitHub cannot assign this account, so the claim is tracked by this comment and the
in progresslabel.