X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Ftime%2F__secs_to_tm.c;h=093d9021ae010f0a13b1cfaf470afb551dcc7d66;hb=4554f155dd23a65fcdfd39f1d5af8af55ba37694;hp=3a3123a1b457bb65dc7b9c61ecaf017db3f671b1;hpb=c82d3bada30cb27e14abda7859da5d2e784830ff;p=musl diff --git a/src/time/__secs_to_tm.c b/src/time/__secs_to_tm.c index 3a3123a1..093d9021 100644 --- a/src/time/__secs_to_tm.c +++ b/src/time/__secs_to_tm.c @@ -60,15 +60,16 @@ int __secs_to_tm(long long t, struct tm *tm) for (months=0; days_in_month[months] <= remdays; months++) remdays -= days_in_month[months]; + if (months >= 10) { + months -= 12; + years++; + } + if (years+100 > INT_MAX || years+100 < INT_MIN) return -1; tm->tm_year = years + 100; tm->tm_mon = months + 2; - if (tm->tm_mon >= 12) { - tm->tm_mon -=12; - tm->tm_year++; - } tm->tm_mday = remdays + 1; tm->tm_wday = wday; tm->tm_yday = yday;